Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
.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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!