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?
can you share a sample project we can look at?
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 )
?
Same problem here.
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
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 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.
Do not do this if you have Update 3 RTM installed
I see the issue now. this is a duplicate of https://github.com/Microsoft/TypeScript/issues/7415, and should be fixed in the next release (see https://github.com/Microsoft/TypeScript/pull/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.
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
"
What version of VS are you using? update 2?
@mhegazy ... no i am using update1... i guess i should be using update 2 correct???
correct.
Got it working with the "workaround". Thank you @mhegazy !!!
@mhegazy This fixed the problem for me ^_^
Can confirm, solution by @mhegazy works with rxjs 5.0.0-beta.6
+1 conformed, solution of @mhegazy works, except for that I had to modify node_modules\typescriptlib\typescriptServices.js under my project folder instead of C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\MicrosoftTypeScript\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 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.
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?
this is a duplicate of #7415, and should be fixed in the next release (see #7507).
Hi @mhegazy it is possible to refresh VS2013 in order to apply the same fix ?
you can use the same steps in https://github.com/Microsoft/TypeScript/issues/8518#issuecomment-217960231 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).
Doesn't work, I've got the API error so have to rolled it back, I've am on the latest service pack
This error "API version mismatch: manager version 0.4, script version 0.5"..
@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\MicrosoftTypeScript\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.
do you have HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0\TypeScriptLanguageService\CustomTypeScriptServicesFileLocation
key set?
Not sure, need to check on 10 hours? What shall I do with it?
@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
Do I have to manually type all these?
This error "API version mismatch: manager version 0.4, script version 0.5"..
@acostaf, you need to install Update2. see https://github.com/Microsoft/TypeScript/issues/8518#issuecomment-217997312
@mhegazy Remember that this issues happens on vs2013 sp5
@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.
@acostaf Visual Studio 2013 is now working for me using that fix. Still having trouble? I have no joy with VS 2015
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.
@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".
@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\typescriptlib\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.
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.
@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
This is hidden by the 0.4.to 0.5
@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.
Can you also post the contents of that log file... AcrivityLog.xml
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
I have a new file available to avoid the errors for VS 2013.
To summarize the workarounds:
For VS 2015:
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.For VS 2013:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\typescriptServices.js
with the file in https://raw.githubusercontent.com/Microsoft/TypeScript/Fix8518-Dev12/lib/typescriptServices.js. First take a local backup though.A different file than before?
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
@acostaf I have good news for you. I followed the last instructions given by @mhegazy step by step.
For VS 2013:
- Install TypeScript 1.8.5 (https://www.microsoft.com/en-us/download/details.aspx?id=48739)
- Replace C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\MicrosoftTypeScript\typescriptServices.js with the file in https://raw.githubusercontent.com/Microsoft/TypeScript/Fix8518-Dev12/lib/typescriptServices.js. First take a local backup though.
After opening a ts file I was suddenly greeted by this error you were having all along.
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 https://github.com/fdecampredon/jsx-typescript/issues/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.
If this works for you invite me to the party. Thanks again to@mhegazy for pointing us in the right direction.
@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
I got it working for VS 2015 update 2 thanks to @mhegazy solution.
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.
Looking for an update to this as well for VS 2015. Dozens upon dozens of these errors.
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.
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.
@dgroh, try copying the file over again. My guess is update 3 overwrote the typescriptService file.
@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
This issue is back after installing VS 2015 Update 3. Could we have a quick-fix version based on 1.8.34?
I have over 250 of these errors drowning out real errors. A quick fix on this would be greatly appreciated.
@twilliamsgsnetx please see my comment for a work around in https://github.com/Microsoft/TypeScript/issues/8518#issuecomment-223156931
@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.
@mhegazy It does work, thankfully. I remember in a previous version doing this fix, it caused my visual studio to crash fairly frequently.
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.
Yeah @rterra, @paulvanbrenk confirmed in #9416 that the fix for typescriptServices.js must be updated.
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):
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-U3/lib/typescriptServices.js. First take a local backup though.For VS 2015 (Update 2):
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.For VS 2013:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\typescriptServices.js
with the file in https://raw.githubusercontent.com/Microsoft/TypeScript/Fix8518-Dev12/lib/typescriptServices.js. First take a local backup though.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)
@Tragetaschen Thanks for point that out.. @DanielRosenwasser Can you add this to the readme for the 2.0 release
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 missing this import statement in your service. import
'rxjs/operators/map';
On 17 Jul 2016 4:18 PM, "bandersen22000" [email protected] 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
https://github.com/Microsoft/TypeScript/issues/8518#issuecomment-233201656,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMHUrThHB3ERvoih2ZC4SBfxu463PWrTks5qWo4LgaJpZM4IZtqg
.
import 'rxjs/add/operators/map'; I has omitted the add in the first post
On 17 Jul 2016 4:25 PM, "Abide Masaraure" [email protected] wrote:
You are missing this import statement in your service. import
'rxjs/operators/map';
On 17 Jul 2016 4:18 PM, "bandersen22000" [email protected] 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
https://github.com/Microsoft/TypeScript/issues/8518#issuecomment-233201656,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMHUrThHB3ERvoih2ZC4SBfxu463PWrTks5qWo4LgaJpZM4IZtqg
.
I have just added that line, but it has no effect,
Same issue as @bandersen22000. TS2339, regardless of whether I import map or not, running Update 3.
@bandersen22000 and @LukeNZ, what version of TS are you running? are you on TS 2.0.0-beta or before?
@mhegazy Running 1.8.10 here.
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 https://github.com/Microsoft/TypeScript/issues/8518#issuecomment-229506507
@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.
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.
@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?
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: https://github.com/Microsoft/TypeScript/issues/8518#issuecomment-229506507
thanks!
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.
@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?
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
Any chance you can upgrade to VS 2015, Angular is much better supported there...
Where did you install TypeScript from?
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
@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" />
I don't have these files at all :(
Should i download and place them manually?
No. First you need to complete your typings.json file, and then run typings install
command.
More info
still erroring out
[image: Inline image 1]
On Tue, Aug 9, 2016 at 1:39 PM, Vahid Nasiri [email protected]
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
https://github.com/Microsoft/TypeScript/issues/8518#issuecomment-238683644,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEsiFzvvXRuKz_rtUAZdCvdXG3Zr37pIks5qeOWWgaJpZM4IZtqg
.
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).
I have the same problem as elemental21
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._.
@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?
what OS are you running on? what version of TS shows in your help\about?
@mhegazy
Windows 8.1 Enterprise
Typescript 2.0.3.0
@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 [email protected]
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
Thanks, @TsengSR I'll give that a shot and report back. I tried just install [email protected] but same Issue. I'll do a repair.
@TsengSR , @mhegazy It didn't work. I deleted the files. Repaired VS 2015. Installed 2.0.3.0. Ran npm install -g [email protected]. Still nothing.
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.
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.
This issue would have been a deal-breaker for using Angular 2 on my new project at work. Thanks @oncidium. That did the trick.
@oncidium ,I was using the built-in version for update 3 which I believe was 1.8.6 so there was nothing to uninstall.
@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.
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.
This is my environment:
I have the following test project...
/node_modules
- generated by npm/tsScripts
- which contains the _tsconfig.json_ file - see below/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...
npm install -g typescript@2
But still the problem exists.
Any suggestions on what I can try next?
In the end, the following fixed it for me:
@Neilski , have you tried unloading and reloading the project. Sometimes you have to prime intellisense. I also benefited from enabling this option.
@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)...
@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.
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.
Can you please share a project we can try with? also i would appreciate it if you file a new issue.
The project is part of a commercial contract, but I will try and replicate the problem in a new project. Thanks for your help.
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.
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
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.
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)
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.
Using rxjs "5.0.0-beta.12" I copied my local "node_modules\typescriptlibtypescriptServices.js" to "c:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\MicrosoftTypeScript\" and restarted Visual Studio 2015 Update 3, the problem was fixed.
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 . 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.
Outside Visual Studio
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!!
Upgrading to the latest TypeScript for Visual Studio 2015 fixed the issue for me.
Most helpful comment
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):
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-U3/lib/typescriptServices.js. First take a local backup though.For VS 2015 (Update 2):
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.For VS 2013:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\typescriptServices.js
with the file in https://raw.githubusercontent.com/Microsoft/TypeScript/Fix8518-Dev12/lib/typescriptServices.js. First take a local backup though.