New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid module name in augmentation #8518

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

Comments

Projects
None yet
@wizardnet972

wizardnet972 commented May 8, 2016

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

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy May 8, 2016

Contributor

can you share a sample project we can look at?

Contributor

mhegazy commented May 8, 2016

can you share a sample project we can look at?

@wizardnet972

This comment has been minimized.

Show comment
Hide comment
@wizardnet972

wizardnet972 May 9, 2016

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 )
?

wizardnet972 commented May 9, 2016

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

This comment has been minimized.

Show comment
Hide comment
@pantonis

pantonis May 9, 2016

Same problem here.

pantonis commented May 9, 2016

Same problem here.

@AloeDream

This comment has been minimized.

Show comment
Hide comment
@AloeDream

AloeDream May 9, 2016

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

AloeDream commented May 9, 2016

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

This comment has been minimized.

Show comment
Hide comment
@bcrigler

bcrigler 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)

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

This comment has been minimized.

Show comment
Hide comment
@AloeDream

AloeDream May 9, 2016

@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.

AloeDream commented May 9, 2016

@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

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy May 9, 2016

Contributor

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.

Contributor

mhegazy commented May 9, 2016

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

This comment has been minimized.

Show comment
Hide comment
@giancarloa

giancarloa May 9, 2016

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
"

giancarloa commented May 9, 2016

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

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy May 9, 2016

Contributor

What version of VS are you using? update 2?

Contributor

mhegazy commented May 9, 2016

What version of VS are you using? update 2?

@giancarloa

This comment has been minimized.

Show comment
Hide comment
@giancarloa

giancarloa May 9, 2016

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

giancarloa commented May 9, 2016

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

@mhegazy

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy May 9, 2016

Contributor

correct.

Contributor

mhegazy commented May 9, 2016

correct.

@bcrigler

This comment has been minimized.

Show comment
Hide comment
@bcrigler

bcrigler May 9, 2016

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

bcrigler commented May 9, 2016

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

@ZenSoftware

This comment has been minimized.

Show comment
Hide comment
@ZenSoftware

ZenSoftware May 10, 2016

@mhegazy This fixed the problem for me ^_^

ZenSoftware commented May 10, 2016

@mhegazy This fixed the problem for me ^_^

@BobbyTable

This comment has been minimized.

Show comment
Hide comment
@BobbyTable

BobbyTable May 11, 2016

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

BobbyTable commented May 11, 2016

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

@mcanic

This comment has been minimized.

Show comment
Hide comment
@mcanic

mcanic 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?

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

This comment has been minimized.

Show comment
Hide comment
@AloeDream

AloeDream May 17, 2016

@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.

AloeDream commented May 17, 2016

@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

This comment has been minimized.

Show comment
Hide comment
@mcanic

mcanic May 17, 2016

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?

mcanic commented May 17, 2016

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

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy May 17, 2016

Contributor

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

Contributor

mhegazy commented May 17, 2016

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

@acostaf

This comment has been minimized.

Show comment
Hide comment
@acostaf

acostaf May 31, 2016

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

acostaf commented May 31, 2016

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

@mhegazy

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy May 31, 2016

Contributor

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).

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

This comment has been minimized.

Show comment
Hide comment
@acostaf

acostaf 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 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

This comment has been minimized.

Show comment
Hide comment
@acostaf

acostaf May 31, 2016

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

acostaf commented May 31, 2016

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

@abidmix

This comment has been minimized.

Show comment
Hide comment
@abidmix

abidmix May 31, 2016

@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

abidmix commented May 31, 2016

@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

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy May 31, 2016

Contributor

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

Contributor

mhegazy commented May 31, 2016

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

@acostaf

This comment has been minimized.

Show comment
Hide comment
@acostaf

acostaf May 31, 2016

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

acostaf commented May 31, 2016

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

@abidmix

This comment has been minimized.

Show comment
Hide comment
@abidmix

abidmix May 31, 2016

@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?

abidmix commented May 31, 2016

@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

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy May 31, 2016

Contributor

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

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

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

This comment has been minimized.

Show comment
Hide comment
@acostaf

acostaf May 31, 2016

@mhegazy Remember that this issues happens on vs2013 sp5

acostaf commented May 31, 2016

@mhegazy Remember that this issues happens on vs2013 sp5

@abidmix

This comment has been minimized.

Show comment
Hide comment
@abidmix

abidmix May 31, 2016

@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 commented May 31, 2016

@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

This comment has been minimized.

Show comment
Hide comment
@abidmix

abidmix May 31, 2016

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

abidmix commented May 31, 2016

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

@brunoalbano

This comment has been minimized.

Show comment
Hide comment
@brunoalbano

brunoalbano May 31, 2016

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.

brunoalbano commented May 31, 2016

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.

@gauravbhanderi231

This comment has been minimized.

Show comment
Hide comment
@gauravbhanderi231

gauravbhanderi231 Aug 9, 2016

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

gauravbhanderi231 commented Aug 9, 2016

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

@VahidN

This comment has been minimized.

Show comment
Hide comment
@VahidN

VahidN Aug 9, 2016

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

VahidN commented Aug 9, 2016

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

@gauravbhanderi231

This comment has been minimized.

Show comment
Hide comment
@gauravbhanderi231

gauravbhanderi231 Aug 9, 2016

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
.

gauravbhanderi231 commented Aug 9, 2016

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

This comment has been minimized.

Show comment
Hide comment
@elemental21

elemental21 Aug 29, 2016

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).

elemental21 commented Aug 29, 2016

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

This comment has been minimized.

Show comment
Hide comment
@daviddcbud

daviddcbud Aug 29, 2016

I have the same problem as elemental21

daviddcbud commented Aug 29, 2016

I have the same problem as elemental21

@mhegazy

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy Sep 24, 2016

Contributor

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..

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..

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Sep 29, 2016

@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?

ghost commented Sep 29, 2016

@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

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy Sep 29, 2016

Contributor

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

Contributor

mhegazy commented Sep 29, 2016

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

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Sep 29, 2016

@mhegazy
Windows 8.1 Enterprise
Typescript 2.0.3.0

ghost commented Sep 29, 2016

@mhegazy
Windows 8.1 Enterprise
Typescript 2.0.3.0

@TsengSR

This comment has been minimized.

Show comment
Hide comment
@TsengSR

TsengSR 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

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

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Sep 29, 2016

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.

ghost commented Sep 29, 2016

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.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Sep 29, 2016

@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.

ghost commented Sep 29, 2016

@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.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Sep 29, 2016

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.

ghost commented Sep 29, 2016

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

This comment has been minimized.

Show comment
Hide comment
@oncidium

oncidium 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.

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 comment has been minimized.

Show comment
Hide comment
@derekmt12

derekmt12 Oct 5, 2016

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

derekmt12 commented Oct 5, 2016

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

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Oct 5, 2016

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

ghost commented Oct 5, 2016

@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

This comment has been minimized.

Show comment
Hide comment
@oncidium

oncidium Oct 5, 2016

@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.

oncidium commented Oct 5, 2016

@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.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Oct 7, 2016

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.

ghost commented Oct 7, 2016

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

This comment has been minimized.

Show comment
Hide comment
@Neilski

Neilski Oct 14, 2016

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

Neilski commented Oct 14, 2016

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
@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Oct 14, 2016

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

image

ghost commented Oct 14, 2016

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

image

@Neilski

This comment has been minimized.

Show comment
Hide comment
@Neilski

Neilski 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

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

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy Oct 17, 2016

Contributor

@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.

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

This comment has been minimized.

Show comment
Hide comment
@Neilski

Neilski 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.

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

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy Oct 19, 2016

Contributor

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

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

This comment has been minimized.

Show comment
Hide comment
@Neilski

Neilski 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 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

This comment has been minimized.

Show comment
Hide comment
@Neilski

Neilski 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.

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

This comment has been minimized.

Show comment
Hide comment
@Argon2000

Argon2000 Nov 17, 2016

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

Argon2000 commented Nov 17, 2016

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

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy Nov 18, 2016

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@Argon2000

Argon2000 Nov 18, 2016

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)

Argon2000 commented Nov 18, 2016

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

This comment has been minimized.

Show comment
Hide comment
@amypellegrini

amypellegrini Nov 25, 2016

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.

amypellegrini commented Nov 25, 2016

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

This comment has been minimized.

Show comment
Hide comment
@invegat

invegat 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.

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

This comment has been minimized.

Show comment
Hide comment
@hobojoe

hobojoe 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?

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

This comment has been minimized.

Show comment
Hide comment
@abidmix

abidmix Dec 1, 2016

@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

abidmix commented Dec 1, 2016

@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

@hobojoe

This comment has been minimized.

Show comment
Hide comment
@hobojoe

hobojoe 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!!

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

This comment has been minimized.

Show comment
Hide comment
@mickeyk

mickeyk Dec 6, 2016

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

mickeyk commented Dec 6, 2016

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

Sharpiro added a commit to Sharpiro/InterviewPrep that referenced this issue Sep 1, 2017

@Microsoft Microsoft locked and limited conversation to collaborators Jun 19, 2018

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