我最近更新了打字稿,棱角分明,以及我的项目中基本上每个图书馆。在我进行此更新之前,问题不存在。从命令行我确保我的代码生成没有错误或警告。但是,当我在Visual Studio代码中打开该项目并对文件进行更改时,它开始将错误突出显示。VSCode忽略tsconfig.json并编译生成不正确错误的单个文件?
它突出了我的进口在顶部说cannot find module 'angular2/core'.
和我@Components
,@Output
S和@Input
。比如说Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.
它也突出了一些,我在.d.ts
文件宣布我Window
属性。
然而,这是我的tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"inlineSourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"noImplicitReturns": true,
"pretty": true
},
"exclude": [ "node_modules" ]
}
看来,当我改变文件VSCode正在建设的单个文件我只是改变而无需使用我的tsconfig。如果我从命令行构建,我会得到零错误或警告。如果我按Ctrl + Shift + B在VSCode内运行构建,然后所有的错误消失。这里是我的tasks.json:
{
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"showOutput": "silent",
"args": ["-p", "."],
"problemMatcher": "$tsc"
}
我怎么能有VSCode寻找使用整个项目的错误和警告,而不仅仅是一个文件?
VSCode 0.10.8 打字稿1.8.7 Linux Mint的17.3 64
就像它的建议,我宁愿不检查node_modules文件夹中的东西。那么,如果你在全球范围内安装了打字稿,你会怎么做?指定c:// [user]的路径也是一个糟糕的选项,因为团队中的其他人将具有不同的用户名。 – Dmitry
不要检入您的vscode设置文件。每个开发者都应该有自己的。 –
恰恰是我的观点。那么你如何解决这个问题呢? – Dmitry