Skip to content

Implement type narrowing for Array.prototype.includes #58989

Closed as not planned
Closed as not planned
@jrandolf

Description

@jrandolf

⚙ Compilation target

ES2016

⚙ Library

ESNext

Missing / Incorrect Definition

Array.prototype.includes and ReadonlyArray.prototype.includes

Sample Code

const candidates = ["foo", "bar"] as const;
const candidate: string = "baz";
// Argument of type '"string"' is not assignable to parameter of type '"foo" | "bar"'.
candidates.includes(candidate);

See #58988

Documentation Link

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions