Visual Studio 2015 RC3 TypeScript Intellisense not

2019-02-27 17:07发布

问题:

I'm using TypeScript 1.8.10 and TypeScript Tools for VS2015 1.8.1.0 Beta. Also, I'm using VS2015 RC3

I tried to upgrade to TypeScript 2.0, and I had the exact same issues, so I went back to TypeScript 1.8. I tried to repair VS2015, to change the tsconfig.json "target" and "module" options, to unload the whole project and setup the TypeScript options in the project file, tried to upgrade the TypeScript tools, and so on; but I still get these errors :

My TypeScript files can't find the @angular packages (Yes they are in my node_module folder), and I even get the Experimental decorators errors, even though I have the "experimentalDecorators": true option in my tsconfig.json. And there are a lot of errors with the TypeScript libraries as you can see in the screenshot below : lib.d.ts and lib.es6.d.ts

The thing is my build compiles without any issue, but I got countless intellisense errors and I can't code in TypeScript anymore so I really can't work anymore at the moment...

Here is my tsconfig.json :

{
  "compilerOptions": {
    "outDir": "./wwwroot/app/",
    "target": "es6",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true
  },
  "exclude": [
    "wwwroot",
    "node_modules",
    "typings",
    "typings/main",
    "typings/main.d.ts"
  ]
}

and here is my package.json :

{
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "scripts": {
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "2.0.0-rc.5",
    "@angular/compiler": "2.0.0-rc.5",
    "@angular/core": "2.0.0-rc.5",
    "@angular/forms": "0.3.0",
    "@angular/http": "2.0.0-rc.5",
    "@angular/platform-browser": "2.0.0-rc.5",
    "@angular/platform-browser-dynamic": "2.0.0-rc.5",
    "@angular/router": "3.0.0-rc.1",
    "@angular/router-deprecated": "2.0.0-rc.2",
    "@angular/upgrade": "2.0.0-rc.5",

    "angular2-in-memory-web-api": "0.0.15",

    "systemjs": "0.19.36",
    "core-js": "^2.4.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.11",
    "zone.js": "^0.6.12"
  },
  "devDependencies": {
    "typescript": "^1.8.10",
    "typings": "^1.0.4",
    "gulp": "^3.9.1",
    "path": "^0.12.7",
    "gulp-clean": "^0.3.2",
    "gulp-concat": "^2.6.0",
    "gulp-typescript": "^2.13.1",
    "gulp-tsc": "^1.1.5",
    "run-sequence": "^1.2.2"
  }
}

Here is a screenshot of my countless intellisense errors :

Any help will be greatly appreciated, I'm really lost with these errors and I don't know what to do anymore... I guess I could completly reinstall VS 2015 but if possible I'd like to avoid doing that.

EDIT : Added project screenshot :

EDIT 2 : I found out that if I change the tsconfig.json target option to "es5", I get Build errors in @angular packages, even though it worked without any issue before. It doesn't change anything about the es6 and es5 libraries tho.

回答1:

If step 2 of Mica's answer was your problem, but you no longer have access to the old typescriptServices.js from C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript then delete (or maybe backup just in case) the typescriptServices.js file and Repair with the TypeScript installer: https://www.microsoft.com/en-us/download/details.aspx?id=48593



回答2:

I still don't know what the problem was, most probably some TypeScript config that went bad in my Visual Studio configuration files, but I solved my problem by uninstalling and re-installing Visual Studio 2015 RC3.



回答3:

I had the same problem after upgrading to typescript 2.0.3. But I just managed it finally, by editing the .jsproj-file. I added this entry to the .jsproj-file (after some import directions)

<PropertyGroup>    
<TypeScriptToolsVersion>2.0</TypeScriptToolsVersion>
</PropertyGroup>

However, there were a couple of other things, I had to solve before:

1) It might be possible, that you followed these steps to replace typescriptService.js some weeks/months ago? If so, replace it again with your (hopefully existing) backup.

2) Download Typescript for Visual Studio and install it https://www.microsoft.com/en-us/download/details.aspx?id=48593

3) Check for KB Patch Update in VS via Tools -> Extensions & Updates. Install it.

4) Try to figure out, if intellisense is working again (just create an new Web/Typescript-project). If its not working in your desired project, try to add PropertyGroup as described above.

Hope it helps :)



回答4:

I guess you do not have node_modules folder in your project.Also if you have then do not include that folder(by right clicking on it and saying include in project) in your project.



回答5:

Just repair the typescript file you have to install once. it will work for me. Right click on your typescript backup file which you install earlier and run it as administrator and click on the repair button. Re-open your project and see the .ts file for intelli-sense