Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

149
Visualizações
.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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda