Skip to content

Array.prototype.includes is not defined on ReadonlyArray<T> #12678

@aluanhaddad

Description

@aluanhaddad

TypeScript Version: 2.1.1 / nightly (2.2.0-dev.20121205)

Code

// A *self-contained* demonstration of the problem follows...
const systemFields = Object.freeze(['id']);

function exclude(key: string) {
  return !systemFields.includes(key);
}

tsconfig.json

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

Expected behavior:
The ReadonlyArray<T> interface defines includes(searchElement: T, fromIndex?: number): boolean
Actual behavior:
Property 'includes' does not exist on type 'ReadonlyArray'

I would be happy to submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions