【发布时间】:2017-01-06 19:09:54
【问题描述】:
我正在使用 TypeScript 1.8.10 和用于 VS2015 1.8.1.0 Beta 的 TypeScript 工具。 另外,我正在使用 VS2015 RC3
我尝试升级到 TypeScript 2.0,但我遇到了完全相同的问题,所以我回到了 TypeScript 1.8。 我尝试修复VS2015,更改tsconfig.json“target”和“module”选项,卸载整个项目并在项目文件中设置TypeScript选项,尝试升级TypeScript工具等等;但我仍然收到这些错误:
我的 TypeScript 文件找不到 @angular 包(是的,它们在我的 node_module 文件夹中),我什至得到了 Experimental decorators 错误,即使我有 "experimentalDecorators": true我的 tsconfig.json 中的选项。 如下图所示,TypeScript 库存在很多错误:lib.d.ts 和 lib.es6.d.ts
问题是我的构建编译没有任何问题,但是我遇到了无数的智能感知错误,我不能再用 TypeScript 编码,所以我现在真的不能再工作了......
这是我的 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"
]
}
这是我的 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"
}
}
这是我无数智能感知错误的截图:
任何帮助将不胜感激,我真的被这些错误迷失了,我不知道该怎么办了......我想我可以完全重新安装 VS 2015,但如果可能的话,我想避免这样做.
编辑:添加项目截图:
编辑 2: 我发现如果我将 tsconfig.json 目标选项更改为“es5”,我会在 @angular 包中遇到构建错误,即使它之前没有任何问题。它不会改变 es6 和 es5 库的任何内容。
【问题讨论】:
-
您的项目结构是什么样的?我正在使用相同的工具,它对我有用(除了愚蠢的 TS1219 错误“对装饰器的实验支持......”,它不会消失,并且与 VS 正确解析 tsconfig 文件有关。在我的项目中,我在项目中包含了 package.json、tsconfig.json 和 typings.json 文件,但排除了根文件夹(
/typings和/node_modules)并且智能感知工作 -
我用我的项目截图编辑了这个问题。它们是项目的根源,之前运行良好......我认为这可能是因为一些 TypeScript 2.0 配置搞砸了我的 Visual Studio,但我不能确定......
-
是的,我在使用 TS2.0 时遇到了很多问题,我最终回滚并不得不进行大量的注册表黑客攻击(它找不到通往 TSC 的正确路径),然后才可以VS2015 再次工作
-
我相信将 TypeScript 升级到 2.0 更改了很多 VS 文件,例如“Microsoft.TypeScript.targets”并完全破坏了 Intellisense ......另外,我发现了一些新东西,我会编辑我的帖子.我还是很伤心……
-
要明确 - 这个问题是在询问 Update 3 的候选版本吗?通常,当人们谈论“Visual Studio X RC Y”时,他们指的是原始产品的 RTM 前预览。但我怀疑您是否在使用 2016 年 8 月的 Visual Studio 2015 预发布版,因为它是在去年 7 月 RTMed 的。
标签: angular typescript visual-studio-2015 intellisense