Property ‘includes’ does not exist on type ‘string[]’

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

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

This should work since TypeScript 2.1.

A related issue.

Explanation

The includes method on Array is supported since ES7 (ES2016). The above will add a missing library file to compilation.

The TypeScript compiler options are documented here.

Lib es2016 or es7 may be sufficient instead of es2017 (not tested).

Leave a Comment