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!
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!
Share Improve this question edited Mar 15, 2017 at 10:19 Angelos Chalaris 6,7078 gold badges53 silver badges80 bronze badges asked Mar 12, 2017 at 8:07 yilihjyyilihjy 731 silver badge4 bronze badges 1-
Try to add options
"lib": [ "es2015", "dom" ],
in your tsconfig.json – yurzui Commented Mar 12, 2017 at 8:14
1 Answer
Reset to default 9On tsconfig.json
, make sure to have "dom"
on your list of libraries.
tsconfig.json
should be looking more or less like this:
{
"pileOnSave": false,
"pilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "monjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2016",
"dom"
]
}
}
Compiler options