我最近更新了打字稿,棱角分明,以及我的項目中基本上每個圖書館。在我進行此更新之前,問題不存在。從命令行我確保我的代碼生成沒有錯誤或警告。但是,當我在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