I wrote an angular2
app in Visual studio code. Recently, I updated Visual Studio Code to 1.10.2. But it has highlighted window
as having an error. When I checked it, I found that it says:
[ts] Cannot find name 'window'.
My code is as follows:
saveCustomIndex(customIndex:any,indexName:string){
window.localStorage.setItem(indexName,JSON.stringify(customIndex));
}
Screenshot
How can I deal with this? Thank you!
On tsconfig.json
, make sure to have "dom"
on your list of libraries.
tsconfig.json
should be looking more or less like this:
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2016",
"dom"
]
}
}
Compiler options
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With