Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

315
Vistas
Use window object in angular2 but vscode "Cannot find name 'window' "

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

Problem screenshot

How can I deal with this? Thank you!

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

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

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda