angular-cli@v1.0.0-rc.0になってVS Codeがエラーだらけになった
2017/02/25に@angular/cliのrcがリリースされた。
今まで何もエラー表示がなかったソースがエラー表示だらけになってしまった。
いろいろ設定を変え元に戻るまでの備忘録。
エラー表示になった箇所
~~~.service.ts
handleKeyboardEvent(event: KeyboardEvent): number { } // ←[ts] Cannot find name 'KeyboardEvent'.
handleMouseMoveEvent(event: MouseEvent): number { } // ←[ts] Cannot find name 'MouseEvent'.
constructor( @Inject('Window') private window: Window) { } // ←[ts] Cannot find name 'Window'.
上記のエラーはエディター上はエラーになっているが、ng build, ng serve, ng test
では
エラーにならずにちゃんと通る。
原因は@angular/cli@v1.0.0-rc.0からtsconfig.jsonが分割されたことによって
VSCodeが読み込む設定のlibにdom
が含まれていないのが原因だった。
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"target": "es2016",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2016", "dom"←!!!ここにdomを追記する!!!
]
}
}