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

150
Vistas
.includes does not exist on type 'string[]'

Trying to use .includes in my component.ts file but it throws me the following error. help me in resolving the issue.

  • Error

Property 'includes' does not exist on type 'string[]'

  • app.component.ts

    permissionCookie: string[]; 
    this.permissionCookie = cookieService.get("permissions").split(",");
    this.permissionFlag = this.permissionCookie.includes("22");
    
  • ts.config

    {
      "compilerOptions": {
        "baseUrl": "",
        "declaration": false,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "lib": ["es6", "dom"],
        "mapRoot": "./",
        "module": "es6",
        "moduleResolution": "node",
        "outDir": "../dist/out-tsc",
        "sourceMap": true,
        "target": "es5",
        "typeRoots": [
          "../node_modules/@types"
        ]
      }
    }
    

    this Property 'includes' does not exist on type 'string[]' didnt help me either

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

0

Try declaring it as,

 private permissionCookie:Array<string>;
constructor() {
  let a = this.permissionCookie.includes("22");
  console.log(a);
}

tsconfig.json -->

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    // "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    // "noImplicitAny": true,
    // "suppressImplicitAnyIndexErrors": true,
    "types": ["jquery"]
  },
  "exclude": [
    "node_modules/*",
    "**/*-aot.ts"
  ]
}
over 4 years ago · Santiago Trujillo Denunciar

0

Add "ES2017" to your "lib" array in tsconfig.json:

{
  "compilerOptions": {
    ...
    "lib": ["dom", "es2017"],
    ...
  }
}

This should work in TypeScript 2.1+.

A related issue.

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