Invalid module name in augmentation #8518

Closed
wizardnet972 opened this Issue May 8, 2016 · 114 comments

Projects

None yet
@wizardnet972

Hi,

In visual studio, i got this error in every d.ts file under node_modules\rxjs\add\observable\ :
Invalid module name in augmentation, module '../../Observable' cannot be found.
example code: declare module '../../Observable' {

how to fix that please?

@mhegazy
Contributor
mhegazy commented May 8, 2016

can you share a sample project we can look at?

@wizardnet972

did visual studio 2015 uses latest typescript release?
Rxjs 5 uses module augumentation introduced at 1.8 (https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#augmenting-globalmodule-scope-from-modules )
?

@pantonis
pantonis commented May 9, 2016

Same problem here.

@AloeDream

Same here, "rxjs": "5.0.0-beta.6" as well as beta.7
VS 2015 with Update 2 and all installed updates.
TS version is of course >1.8

@bcrigler
bcrigler commented May 9, 2016

Installed the latest 1.8.6 download from Microsoft as a VS extension experiencing the same issue...

How do I point Visual Studio to use the local version of Typescript installed locally within my project? (which I have 1.8.10 installed locally)

@AloeDream

@bcrigler no way to point VS to use local TypeScript compiler. We have to wait next extention update.
Or you can separate your web project into VS Code project + Service project for C# logic and use local TS with VS code.

@mhegazy
Contributor
mhegazy commented May 9, 2016 edited

Do not do this if you have Update 3 RTM installed

I see the issue now. this is a duplicate of #7415, and should be fixed in the next release (see #7507).

As work arounds for now, you can replace C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\typescriptServices.js with the file in https://raw.githubusercontent.com/Microsoft/TypeScript/Fix8518/lib/typescriptServices.js. First take a local backup though.

@mhegazy mhegazy added Duplicate and removed Needs More Info labels May 9, 2016
@giancarloa

Hi there @mhegazy ... I tried your suggestion... but now when I try to open the project I get the error "API version mismatch: manager version 0.4, script version 0.5"... any ideas? thanks

tserr
"

@mhegazy
Contributor
mhegazy commented May 9, 2016

What version of VS are you using? update 2?

@giancarloa

@mhegazy ... no i am using update1... i guess i should be using update 2 correct???

@mhegazy
Contributor
mhegazy commented May 9, 2016

correct.

@bcrigler
bcrigler commented May 9, 2016

Got it working with the "workaround". Thank you @mhegazy !!!

@ZenSoftware

@mhegazy This fixed the problem for me ^_^

@VahidN VahidN referenced this issue in angular/angular May 10, 2016
Closed

Issue with typings in WebWorker bundle #4902

@deadZedd
deadZedd commented May 11, 2016 edited

Can confirm, solution by @mhegazy works with rxjs 5.0.0-beta.6

@mcanic
mcanic commented May 17, 2016

+1 conformed, solution of @mhegazy works, except for that I had to modify node_modules\typescript\lib\typescriptServices.js under my project folder instead of C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\typescriptServices.js.

Is this a typescript bug then? If so, will it be fixed in the next version, and is this the right fix?

@AloeDream

@mcanic I've got it working under C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\typescriptServices.js.
It's not a bug, it's a missing feature in current VS tools version.

@mcanic
mcanic commented May 17, 2016 edited

I'm sure you are right, because I saw that the tsc command compiled fine, but I don't get how this can be a missing feature in the current VS tools version?

Update: of course: it is not typescript, it IS the VS extension itself where the fix was applied, I get it now.
Should we report this bug somewhere?

@mhegazy
Contributor
mhegazy commented May 17, 2016

this is a duplicate of #7415, and should be fixed in the next release (see #7507).

@mhegazy mhegazy closed this May 20, 2016
@Sharpiro Sharpiro added a commit to Sharpiro/InterviewPrep that referenced this issue May 25, 2016
@Sharpiro Sharpiro Successfully upgraded to angular 2 RC1 7ed661a
@acostaf
acostaf commented May 31, 2016

Hi @mhegazy it is possible to refresh VS2013 in order to apply the same fix ?

@mhegazy
Contributor
mhegazy commented May 31, 2016

you can use the same steps in #8518 (comment) for VS 2013, the location would be C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\typescriptServices.js (12.0 instead of 14.0 in the path).

@acostaf
acostaf commented May 31, 2016

Doesn't work, I've got the API error so have to rolled it back, I've am on the latest service pack

@acostaf
acostaf commented May 31, 2016

This error "API version mismatch: manager version 0.4, script version 0.5"..

@abidmix
abidmix commented May 31, 2016 edited

@mhegazy I installed Visual Studio Service pack 2 , applied the hotfix(replacing content of the C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\typescriptServices.js file with https://raw.githubusercontent.com/Microsoft/TypeScript/Fix8518/lib/typescriptServices.js and the errors do not go away for me. What version of typescript were you using when you applied this fix. Project builds successfully though but these errors are disheartening.

image

@mhegazy
Contributor
mhegazy commented May 31, 2016

do you have HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0\TypeScriptLanguageService\CustomTypeScriptServicesFileLocation key set?

@acostaf
acostaf commented May 31, 2016

Not sure, need to check on 10 hours? What shall I do with it?

@abidmix
abidmix commented May 31, 2016 edited

@mhegazy . I am missing this key under 14(2015). And I can see in it under 12(Visual Studio 2013).If I am to set this key what should I set the values to.
I can see the key for VS2013
image
Do I have to manually type all these?

@mhegazy
Contributor
mhegazy commented May 31, 2016

This error "API version mismatch: manager version 0.4, script version 0.5"..

@acostaf, you need to install Update2. see #8518 (comment)

@acostaf
acostaf commented May 31, 2016

@mhegazy Remember that this issues happens on vs2013 sp5

@abidmix
abidmix commented May 31, 2016 edited

@mhegazy , I can confirm that same solution you provided works in VS2013 update 5 without errors. So I guess, this issue needs to be addressed in VS 2015. I am using Visual Studio 2015 update 2.

@abidmix
abidmix commented May 31, 2016 edited

@acostaf Visual Studio 2013 is now working for me using that fix. Still having trouble? I have no joy with VS 2015

@brunoalbano

I am facing the same issue trying to use Angular 2/Ionic 2 in VS 2015 Update 2: TS2664 Invalid module name in augmentation, module '../../Observable' cannot be found.

@acostaf
acostaf commented May 31, 2016

@adidmix what did you did? I replaced the file but did not worked keep getting "API version mismatch: manager version 0.4, script version 0.5".

@abidmix
abidmix commented May 31, 2016 edited

@acostaf Did you back up your original typescript.js. Revert to the original file but change the one in the node_modules folder as @mcanic pointed out. The path is node_modules\typescript\lib\typescriptServices.js . After changing this file restart Visual Studio, keeping your fingers crossed, and have a look again on the error list , but this time silently murmuring Visual Studio to forever remain silent.

@Argon2000
Argon2000 commented Jun 1, 2016 edited

My VS2015 hangs on startup after replacing typescriptServices.js with the linked file. Saw now that I have update 1, no notification about update 2 in VS2015. Downloading U2 and trying again.

@acostaf
acostaf commented Jun 1, 2016 edited

@abidmix, @mhegazy and @mcanic thanks very much for your help, replacing the typescriptServices.js file fixed the compilation and the intellisense within VS2013, however the only way I can test this is closing several errors, I keep getting the error every time I open the editor, if the last file opened is a .ts file the whole IDE is blocked since the 0.4 to 0.5 error pops at the same time at the generic error for extensions.

@mhegazy any plan to release a new version of the extension to get around this?

@abidmix do you get the errors? is vs2013 clean for you ?

This sat in top of the generic error blocking VS2013 since the generic got the focus
fourtofive

This is hidden by the 0.4.to 0.5
overlapping

@abidmix
abidmix commented Jun 1, 2016 edited

@acostaf I do not get any error in Visual Studio 2013. Can you confirm if the version/bulid of Visual Studio 2013 you are using is the same as one posted below. Then if the same, we can go ahead and dissect your project file.
image
Can you also post the contents of that log file... AcrivityLog.xml

@mhegazy
Contributor
mhegazy commented Jun 1, 2016

For VS 2013, you need to install the latest plugin (TS 1.8.5), see https://www.microsoft.com/en-us/download/details.aspx?id=48739

@mhegazy
Contributor
mhegazy commented Jun 1, 2016

I have a new file available to avoid the errors for VS 2013.

@mhegazy
Contributor
mhegazy commented Jun 1, 2016

To summarize the workarounds:

For VS 2015:

For VS 2013:

@acostaf
acostaf commented Jun 1, 2016

A different file than before?

@mhegazy
Contributor
mhegazy commented Jun 1, 2016

yes. the VS 2013 one is https://raw.githubusercontent.com/Microsoft/TypeScript/Fix8518-Dev12/lib/typescriptServices.js.

The only difference is the a version (0.5 in VS 2015 vs 0.4 in VS 2013) this avoids the message "API Version Mismatch" you would get in VS 2013

@abidmix
abidmix commented Jun 2, 2016 edited

@acostaf I have good news for you. I followed the last instructions given by @mhegazy step by step.

For VS 2013:

After opening a ts file I was suddenly greeted by this error you were having all along.

image

Looking closely at the error sparked some idea. Its complaining somehow about a version mismatch. I googled the above error and landed on a forum fdecampredon#4 where someone manually changed the vesion back to 0.4 in the typescript.js file. Now determined more than ever , I replaced the line ts.servicesVersion = "0.5"; with ts.servicesVersion = "0.4"; then saved the file. Opened a ts file again in Visual Studio 2013 and then voila!!! no error showed this time, and my intellisense shined in admiration.

image

If this works for you invite me to the party. Thanks again to@mhegazy for pointing us in the right direction.

@acostaf
acostaf commented Jun 2, 2016

@mhegazy, @abidmix thanks guys I can confirm that the latest file fixed the issue, it is now working properly, resolving everything from angular and and rxjs properly

@manuelreina

I got it working for VS 2015 update 2 thanks to @mhegazy solution.

@tylerjgarland
tylerjgarland commented Jun 8, 2016 edited

I'm not sure if I missed it or not, but does anyone know where we can monitor for an official patch of this? From what I've read, it's a VS library and not an issue with the typescript compiler itself. Does anyone know if it will be included in VS 2015 Update 3?

Just to clarify: exchange the typescriptServices.js works. I've just had to help my coworkers manually set there machines for this and we are onboarding 4 more. Was hoping update 3 contains the fix.

@twilliamsgsnetx
twilliamsgsnetx commented Jun 8, 2016 edited

Looking for an update to this as well for VS 2015. Dozens upon dozens of these errors.

@mhegazy
Contributor
mhegazy commented Jun 9, 2016

Does anyone know if it will be included in VS 2015 Update 3?

No. This should be included in the next release, TS 2.0. hopefully withing the next few weeks.

@dgroh
dgroh commented Jun 14, 2016 edited

I copied the typescriptService content from the link above and worked with visual studio update 2. After updating to update 3 RC, it stopped working.

@tylerjgarland

@dgroh, try copying the file over again. My guess is update 3 overwrote the typescriptService file.

@dgroh
dgroh commented Jun 14, 2016

@tylerjgarland what I did was to rollback to the old file (the original one) and for now is working. It seems like the bug is gone

@Tragetaschen

This issue is back after installing VS 2015 Update 3. Could we have a quick-fix version based on 1.8.34?

@twilliamsgsnetx

I have over 250 of these errors drowning out real errors. A quick fix on this would be greatly appreciated.

@mhegazy
Contributor
mhegazy commented Jun 28, 2016

@twilliamsgsnetx please see my comment for a work around in #8518 (comment)

@deadZedd

@mhegazy Using the 2015 update 2 fix-file you provide stops typescript from compiling on my VS update 3 (silent, no output). Using the original backup-file from update 2 doesnt compile TS either (as someone suggested) so my only "solution" to get it compiling is to use the original update 3 file and live with the errors.

@twilliamsgsnetx

@mhegazy It does work, thankfully. I remember in a previous version doing this fix, it caused my visual studio to crash fairly frequently.

@rterra
rterra commented Jun 29, 2016

I seems that work if Upgrade 3 RC but not with final version. I copy over VS 15 Update 3 and typescript compilation stopped with unknown exception.

@GeorgDangl

Yeah @rterra, @paulvanbrenk confirmed in #9416 that the fix for typescriptServices.js must be updated.

@mhegazy
Contributor
mhegazy commented Jun 29, 2016 edited

EDIT: For Visual Studio 2015, installing TS 2.0.3 is the recommended fix. This workaround is not needed.

EDIT 2: If you have ever applied this fix before, please uninstall TS 1.8.* before installing TS 2.0.. Also please make sure that the typescriptServices.js file has been deleted after uninstalling TS 1.8..


Here are the updated instructions for VS 2015 Update 3

To summarize the workarounds:

For VS 2015 (Update 3):

For VS 2015 (Update 2):

For VS 2013:

@Tragetaschen
Tragetaschen commented Jul 14, 2016 edited

Ugh: Here is a word of caution for VS users:

If you followed the workaround here and replaced the typescriptServices.js in the Program Files folder, the 2.0.0 beta installer won't replace that with the new version. When I opened VS 2015 after the 2.0.0 installer ran, I was shocked to see 47000ish errors starting with those from lib.d.ts complaining about a readonly field.

For me, the solution was to delete typescriptServices.js from the above folder and let the installer do its Repair work.

Edit: Removing that file before running the 2.0.0 installer for the first time works, too.

(I hope I mentioned all necessary search terms in this comment)

@paulvanbrenk
Member

@Tragetaschen Thanks for point that out.. @DanielRosenwasser Can you add this to the readme for the 2.0 release

@bandersen22000

I still have this error with VS 2015, update 3 TS2339 Property 'map' does not exist on type 'Observable'
I have tried all fixes with no solution.
My package.json:

   {
        "version": "1.0.0",
        "name": "ASP.NET",
        "private": true,
      "dependencies": {
       "angular2": "2.0.0-beta.17",
        "es6-shim": "^0.35.0",
        "systemjs": "^0.19.26",
        "bootstrap": "^3.3.6"
      },
      "devDependencies": {
        "gulp": "^3.9.1",
        "rimraf": "^2.5.2",
        "gulp-convert-encoding": "^0.0.3",
        "gulp-typescript": "^2.13.6"
      }
    }

My service call file:

   import { Injectable } from 'angular2/core';
    import { Account } from '../Model/Account';
    import {Http, Response} from 'angular2/http';
    import {Observable} from 'rxjs/Observable';

    @Injectable()
    export class AccountService {
        constructor(private _http: Http) {

        }

        getMembers(): Observable<Account[]> {
            return this._http.get('http://localhost/amsApi/api/member/GetallMembers/').map((response: Response) => <Account[]>response.json())
                .catch(this.errorHandler);
        }

        private errorHandler(error: Response) {
            alert(Error);
            return Observable.throw('Server error');
        }
    }

Does anyone have a solution for it ? I have also tried the answer from mhegazy with no success.

@abidmix
abidmix commented Jul 17, 2016

You are missing this import statement in your service. import
'rxjs/operators/map';
On 17 Jul 2016 4:18 PM, "bandersen22000" notifications@github.com wrote:

I still have this error with VS 2015, update 3 TS2339 Property 'map'
does not exist on type 'Observable'

I have tried all fixes with no solution.
My package.json:

{
"version": "1.0.0",
"name": "ASP.NET",
"private": true,
"dependencies": {
"angular2": "2.0.0-beta.17",
"es6-shim": "^0.35.0",
"systemjs": "^0.19.26",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"gulp": "^3.9.1",
"rimraf": "^2.5.2",
"gulp-convert-encoding": "^0.0.3",
"gulp-typescript": "^2.13.6"
}
}

My service call file:

import { Injectable } from 'angular2/core';
import { Account } from '../Model/Account';
import {Http, Response} from 'angular2/http';
import {Observable} from 'rxjs/Observable';

@Injectable()
export class AccountService {
    constructor(private _http: Http) {

    }

    getMembers(): Observable<Account[]> {
        return this._http.get('http://localhost/amsApi/api/member/GetallMembers/').map((response: Response) => <Account[]>response.json())
            .catch(this.errorHandler);
    }

    private errorHandler(error: Response) {
        alert(Error);
        return Observable.throw('Server error');
    }
}

Does anyone have a solution for it ? I have also tried the answer from
mhegazy with no success.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#8518 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMHUrThHB3ERvoih2ZC4SBfxu463PWrTks5qWo4LgaJpZM4IZtqg
.

@abidmix
abidmix commented Jul 17, 2016

import 'rxjs/add/operators/map'; I has omitted the add in the first post
On 17 Jul 2016 4:25 PM, "Abide Masaraure" abidmix@gmail.com wrote:

You are missing this import statement in your service. import
'rxjs/operators/map';
On 17 Jul 2016 4:18 PM, "bandersen22000" notifications@github.com wrote:

I still have this error with VS 2015, update 3 TS2339 Property 'map'
does not exist on type 'Observable'

I have tried all fixes with no solution.
My package.json:

{
"version": "1.0.0",
"name": "ASP.NET",
"private": true,
"dependencies": {
"angular2": "2.0.0-beta.17",
"es6-shim": "^0.35.0",
"systemjs": "^0.19.26",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"gulp": "^3.9.1",
"rimraf": "^2.5.2",
"gulp-convert-encoding": "^0.0.3",
"gulp-typescript": "^2.13.6"
}
}

My service call file:

import { Injectable } from 'angular2/core';
import { Account } from '../Model/Account';
import {Http, Response} from 'angular2/http';
import {Observable} from 'rxjs/Observable';

@Injectable()
export class AccountService {
    constructor(private _http: Http) {

    }

    getMembers(): Observable<Account[]> {
        return this._http.get('http://localhost/amsApi/api/member/GetallMembers/').map((response: Response) => <Account[]>response.json())
            .catch(this.errorHandler);
    }

    private errorHandler(error: Response) {
        alert(Error);
        return Observable.throw('Server error');
    }
}

Does anyone have a solution for it ? I have also tried the answer from
mhegazy with no success.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#8518 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMHUrThHB3ERvoih2ZC4SBfxu463PWrTks5qWo4LgaJpZM4IZtqg
.

@bandersen22000

I have just added that line, but it has no effect,

@LukeNZ
LukeNZ commented Jul 17, 2016 edited

Same issue as @bandersen22000. TS2339, regardless of whether I import map or not, running Update 3.

@mhegazy
Contributor
mhegazy commented Jul 17, 2016

@bandersen22000 and @LukeNZ, what version of TS are you running? are you on TS 2.0.0-beta or before?

@LukeNZ
LukeNZ commented Jul 17, 2016

@mhegazy Running 1.8.10 here.

@mhegazy
Contributor
mhegazy commented Jul 17, 2016

This issue is a duplicate of #7415. #7415 is fixed in TS 2.0 and later. TS 1.8.* dose not contain the fix.

So either upgrade to TS 2.0-beta or later, or follow the workaround steps in #8518 (comment)

@LukeNZ
LukeNZ commented Jul 17, 2016 edited

@mhegazy This error occurs with the workaround installed. I added the correct version of typescriptServices.js back into the required directory after updating to Update 3.

I will try upgrading to TypeScript 2.

@bandersen22000

Hi, I resolved the issue by downgrading Angular2 and rxjs to the following settings:

  {
        "version": "1.0.0",
        "name": "ASP.NET",
        "private": true,
      "dependencies": {
      "angular2": "2.0.0-beta.14",
    "es6-shim": "^0.35.0",
    "systemjs": "^0.19.26",
    "bootstrap": "^3.3.6",
    "rxjs": "5.0.0-beta.2"
      },
      "devDependencies": {
        "gulp": "^3.9.1",
        "rimraf": "^2.5.2",
        "gulp-convert-encoding": "^0.0.3",
        "gulp-typescript": "^2.13.6"
      }
    }

Maybe you only have to downgrade rxjs, but these settings worked for me.

@johnpankowicz
johnpankowicz commented Jul 20, 2016 edited

@mhegazy - You say "Do not do this if you have Update 3 RTM installed" I have VS Pro 2015 v4.6.01038. Update 3. The fix works for this. This is not the "RTM" - is it? I got it through MSDN. Is there a specific reason that you qualify your statement with "RTM". Also what is the reason for the warning? What problems can result?

@mhegazy
Contributor
mhegazy commented Jul 21, 2016

this thread has been going on for a while now, and i am sure i said a lot of wrong things by now :)

here is the updated work around documentation for Update 3: #8518 (comment)

@shimozurdo

thanks!

@gauravbhanderi231
gauravbhanderi231 commented Aug 9, 2016 edited

i am having the same issue. Cannot compile angular *.ts files. I updated to latest version of typescript but when i try to check the version through command prompt(tsc -v) it opens up a tsc.js file . dont know what the issue is there. I did replace the typescriptServices.js file, no luck there as well.
image

image

@paulvanbrenk
Member

@gauravbhanderi231 Which version of TypeScript does it say in Help - About in Visual Studio? What did you replace the typescriptservices.js with? The fact that tsc -v opens the js file makes me wonder if something else is wrong. Which version of VS are you using?

@gauravbhanderi231
gauravbhanderi231 commented Aug 9, 2016 edited

Hi @paulvanbrenk ,

Thanks for the response. I looked at the help-About VS and couldn't find typescript listed under Installed Products. That is so strange because i am able to create a typescript project.I have typescript 1.8 installed
About the typescriptservices.js file i used the one mentioned here: https://raw.githubusercontent.com/Microsoft/TypeScript/Fix8518-Dev12/lib/typescriptServices.js

image

@paulvanbrenk
Member

Any chance you can upgrade to VS 2015, Angular is much better supported there...

Where did you install TypeScript from?

@gauravbhanderi231

I wish i could but i am trying to use angular2 with an existing application that we have vs13. I installed typescript from https://visualstudiogallery.msdn.microsoft.com/9d0e9172-244a-4943-94e5-bd24dffd9536

@VahidN
VahidN commented Aug 9, 2016

@gauravbhanderi231
Add these lines at the beginning of the main.ts file:

/// <reference path="../typings/browser/ambient/core-js/index.d.ts" />
/// <reference path="../typings/browser/ambient/node/index.d.ts" />

@gauravbhanderi231

I don't have these files at all :(
Should i download and place them manually?

@VahidN
VahidN commented Aug 9, 2016

No. First you need to complete your typings.json file, and then run typings install command.
More info

@gauravbhanderi231

still erroring out

[image: Inline image 1]

On Tue, Aug 9, 2016 at 1:39 PM, Vahid Nasiri notifications@github.com
wrote:

No. First you need to complete your typings.json
https://github.com/angular/quickstart/blob/master/typings.json file,
and then run typings install command.
More info
https://angular.io/docs/ts/latest/guide/typescript-configuration.html


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#8518 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEsiFzvvXRuKz_rtUAZdCvdXG3Zr37pIks5qeOWWgaJpZM4IZtqg
.

@elemental21
elemental21 commented Aug 29, 2016 edited

Is anyone else having an issue with the tsconfig.json compileOnSave setting after implementing this fix? It seems that as soon as I switched the typescriptServices.js back to the original 1.8.x file compileOnSave started working again. I'm running vs2015 with Update 3 and Typescript 1.8.36.0 (my PATH setting has been corrected so I am actually using that version).

@daviddcbud

I have the same problem as elemental21

@mhegazy
Contributor
mhegazy commented Sep 24, 2016

For Visual Studio 2015, installing TS 2.0.3 is the recommended fix. This workaround is not needed.

If you have ever applied this fix before, please uninstall TS 1.8.* before installing TS 2.0.. Also please make sure that the typescriptServices.js file has been deleted after uninstalling TS 1.8..

@tylerjgarland

@mhegazy , I applied this fix a long time ago. I didn't have any extra version of typescript installed. Just the one that was bundled with Update 3 I guess. I just installed typescript 2.0.3 and intellisense is no longer working. I came to here and it said to delete the typescriptServices.js file BEFORE installing but I had already installed. I deleted the services file, repaired the 2.0.3 installation but intellisense is still not working. Do you have any triage steps?

@mhegazy
Contributor
mhegazy commented Sep 29, 2016

what OS are you running on? what version of TS shows in your help\about?

@tylerjgarland
tylerjgarland commented Sep 29, 2016 edited

@mhegazy
Windows 8.1 Enterprise
Typescript 2.0.3.0

@TsengSR
TsengSR commented Sep 29, 2016

@tylerjgarland: Had similar issue. After uninstalling it and reinstalling it, even code highlighting or formatting would work, not even with 1.8 Version. So I installed the tools and ran npm install -g typescript@2.0 and after a Visual Studio restart it started working again.

If that doesn't work delete the file in the visual studio folder that was replaced in the steps above, do a Visual Studio repair (not TypeScript), the install TypeScript and if still necessary, repeat the step above

@tylerjgarland

Thanks, @TsengSR I'll give that a shot and report back. I tried just install typescript@2.0 but same Issue. I'll do a repair.

@tylerjgarland

@TsengSR , @mhegazy It didn't work. I deleted the files. Repaired VS 2015. Installed 2.0.3.0. Ran npm install -g typescript@2.0. Still nothing.

@tylerjgarland

I updated gulp-typescript to 3.0.1 and typescript 2.0.1 in my package.json. Ran a typescript build using gulp and then intellisense started working. I'm not actually sure what fixed it. Hell, it could be just keeping it open for a while too. I have to upgrade the other devs though so if anyone has clarity on how that fixed my issues, I'd be very thankful.

@oncidium
oncidium commented Oct 1, 2016

I had the same problem. I ended up going to programs and feature and uninstalled all previous versions of TypeScript Tools for Microsoft Visual studio, then I installed the latest version of TypeScript tools version 2.X https://www.microsoft.com/en-us/download/details.aspx?id=48593 and this fixed the problem.

@derekmt12

This issue would have been a deal-breaker for using Angular 2 on my new project at work. Thanks @oncidium. That did the trick.

@tylerjgarland

@oncidium ,I was using the built-in version for update 3 which I believe was 1.8.6 so there was nothing to uninstall.

@oncidium
oncidium commented Oct 5, 2016 edited

@tylerjgarland As far as uninstalling, I figure you can never be too careful with these things. What fixed my problem is actually installing Visual Studio's TypeScript tools 2.0.

@tylerjgarland
tylerjgarland commented Oct 7, 2016 edited

So I have a workaround but it's obnoxious. If I type the correct import statement, save it, and restart visual studio it seems the intellisense cache is rebuilt and it works.

@Neilski
Neilski commented Oct 14, 2016 edited

vs-angular-error

This is my environment:

  • Visual Studio Professional 2015 Version 14.0.25431.01 Update 3
  • JetBrains ReSharper Ultimate 2016.2.2 (current)
  • TypeScript Version 2.0.3
  • NPM Version 3.10.9

I have the following test project...

  1. /node_modules - generated by npm
  2. /tsScripts - which contains the tsconfig.json file - see below
  3. /tsScripts/App1 - which contains the TypeScript files for my application
// tsconfig.json
{
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "commonjs",
    "noEmitOnError": true,
    "noImplicitAny": false,
    "outDir": "./",
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "moduleResolution": "node"
  },
  "exclude": [
    "node_modules",
    "libs",
    "typings/index",
    "typings/index.d.ts"
  ]
}

When editing a .ts file in /tsScripts/App1, the import { NgModule} from '@angular/core'; shows the intellisense error Cannot find module '@angular/core' (for example). The folder structure /node_modules/@angular/core exists.

The .ts files compile and the project runs successfully without compile-time warnings or errors, perhaps suggesting this is a Visual Studio tooling problem rather than a core TypeScript issue(?)

To try and resolve this problem I have...

  • uninstalled (with manual cleanup) and re-nstalled TS 2.0.3
  • Tried running npm install -g typescript@2

But still the problem exists.

Any suggestions on what I can try next?

UPDATE

In the end, the following fixed it for me:

  1. Go to Tools -> Options -> Text Editor -> TypeScript -> Project -> General
  2. Tick "Automatically compile TypeScript files which are not part of a project"
  3. Select "Use CommonJS code generation for modules
@tylerjgarland

@Neilski , have you tried unloading and reloading the project. Sometimes you have to prime intellisense. I also benefited from enabling this option.

image

@Neilski
Neilski commented Oct 15, 2016

@tylerjgarland , I'd pretty much tried everything and had got into the habit of actually exiting Visual Studio and, fairly regularly rebooting the whole PC (ain't SSDs great?), but nothing worked until I played around with VS's TypeScript options as described above, and immediately everything started to work.

Thinking about it, I guess this makes sense, as the NPM imported/generated code was not included in the project, but it did seem odd that this fix was better/more prolifically mentioned in the posts that I had looked at.

For reference, this is what fixed it for me (which is in alignment with my tscconfig.json settings)...

typescript-options

@mhegazy
Contributor
mhegazy commented Oct 17, 2016

@Neilski these changes should have no impact if you have a tsconfig.json. i would say you are running into a different issue. Please file an new issue and share some context to be able to investigate it.

@Neilski
Neilski commented Oct 19, 2016

I do have a tsconfig.json file, the only thing that might be unusual is that is is placed in the '/tsScripts' folder off the root. This folder is where my TypeScript source files are kept, for example '/tsScripts/App1/', '/tsScripts/App2/' etc.

For your reference, here is my tsconfig.json...

{
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "commonjs",
    "noEmitOnError": true,
    "noImplicitAny": false,
    "outDir": "./",
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "moduleResolution": "node",
    "types": ["node"]
  },
  "exclude": [
    "node_modules",
    "typings/index",
    "typings/index.d.ts"
  ]
}

I am not sure of why, but the project builds with the TypeScript Project Options set as described, but would not without the automatic compilation set.

@mhegazy
Contributor
mhegazy commented Oct 19, 2016

Can you please share a project we can try with? also i would appreciate it if you file a new issue.

@Neilski
Neilski commented Nov 1, 2016

The project is part of a commercial contract, but I will try and replicate the problem in a new project. Thanks for your help.

@Neilski
Neilski commented Nov 8, 2016

We have tried to replicate this problem, but without success. Interestingly, if we turn these settings off in the original project, it now compiles without error. As far as I know, nothing else has changed.

So, in summary, it appears that the problem has resolved itself, just not sure how/why.

@Argon2000

Wow, had a big headache today when updating to TypeScript 2.0.6.. All errors returned that was fixed with the custom typescriptServices.js file (e.g. "Cannot find module 'angular2/core'", "set 'experimentalDecorators' to true", "'example' is not a valid property for window" etc. etc.).

This is what my tsconfig.json file looked like:

{
  "compilerOptions": {
    "noImplicitAny": true,
    "noEmitOnError": false,
    "sourceMap": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "module": "system",
    "moduleResolution": "Node",
    "target": "es5",
    "noImplicitUseStrict": true,
    "allowSyntheticDefaultImports": true,
    "outDir": "scripts",
    "outFile": "scripts/app.js"
  },
  "include": [
    "App",
    "Scripts"
  ],
  "exclude": [
    "node_modules",
    "Scaffolding"
  ],
  "compileOnSave": true
}

I tried everything, uninstalled all previous versions of typescript, tools for VS2015, rebooted several times etc. Nothing helped.

Then I started mixturing with the settings in my tsconfig.json file and noticed that it started working after i removed several options. And after some trial and error of adding them back one by one, the culprit was found to be the "include" option.

So my current tsconfig.json looks like this (and works with 2.0.6):

{
  "compilerOptions": {
    "noImplicitAny": true,
    "noEmitOnError": false,
    "sourceMap": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "module": "system",
    "moduleResolution": "Node",
    "target": "es5",
    "noImplicitUseStrict": true,
    "allowSyntheticDefaultImports": true,
    "outDir": "scripts",
    "outFile": "scripts/app.js"
  },
  "exclude": [
    "node_modules",
    "Scaffolding"
  ],
  "compileOnSave": true
}

Strange thing is that the previous tsconfig.json worked perfectly fine with TS 1.8.x

@mhegazy
Contributor
mhegazy commented Nov 18, 2016

Strange thing is that the previous tsconfig.json worked perfectly fine with TS 1.8.x

include was not supported for TS 1.8, looks like you added it before, and was never used.

@Argon2000
Argon2000 commented Nov 18, 2016 edited

Ah, that would explain it. Thanks!

Edit: Acctually, it explains 'cannot find module ...' and '... not valid property of window' errors. But the 'experimentalDecorators' should not have been an error? (For .ts files in /App)

@amypellegrini

Apologies if this comment does not apply, but I don't have time to follow all the details in this thread.

I restored a file for a hotfix suggested by @mhegazy on May 9, in case anyone needs it:

https://gist.github.com/amypellegrini/a48eb0c21f65dcb501766e69c2d8b765.js

Advice: use it at your own risk and do some research first,

I'm applying this hotfix as suggested by my colleagues and there are probably many details I'm missing related to this issue, I just want to make sure anyone else can have access to this file in case it needs to.

@invegat
invegat commented Nov 28, 2016

Using rxjs "5.0.0-beta.12" I copied my local "node_modules\typescript\lib\typescriptServices.js" to "c:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript" and restarted Visual Studio 2015 Update 3, the problem was fixed.

@hobojoe
hobojoe commented Dec 1, 2016

Hi,

I've tried following all these tricks but none worked.

I created a brand new project on github with the problem:
https://github.com/hobojoe/TestApp

Does anyone have a clue of what could be the problem?

@abidmix
abidmix commented Dec 1, 2016 edited

@hobojoe . I added an es6-shim.d.ts to your project ...added a map import in your service and a reference to the es6-shim.d.ts and your app builds fine inside and outside visual studio. See the changes I made to your project. Confirm if this resolves your issue.

image

Outside Visual Studio

image

@VahidN VahidN referenced this issue in chsakell/aspnet5-angular2-typescript Dec 1, 2016
Open

Typescript definition files errors #28

@hobojoe
hobojoe commented Dec 4, 2016

Hi @abidmix
I have performed the steps suggested by you and it fixed the problem.

The strange thing is that, as mentioned by @VahidN, I was following a guide from @chsakell and I could use his project without the need to follow the steps you described.

That is odd to me, that for one project everything works without adding the custom import and mine doesn't and I have to add it to work....

Thanks anyway, your assistance was very helpful!!

@mickeyk
mickeyk commented Dec 6, 2016

Upgrading to the latest TypeScript for Visual Studio 2015 fixed the issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment