Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement type narrowing for Array.prototype.includes #58989

Closed
jrandolf opened this issue Jun 24, 2024 · 3 comments
Closed

Implement type narrowing for Array.prototype.includes #58989

jrandolf opened this issue Jun 24, 2024 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@jrandolf
Copy link

jrandolf commented Jun 24, 2024

⚙ 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

@MartinJohns
Copy link
Contributor

Duplicate of #55090 / #14520.

@jrandolf jrandolf closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 2024
@jrandolf jrandolf reopened this Jun 24, 2024
@jrandolf
Copy link
Author

Looks like this issue is a sub-issue of #14520 as the parent can fix this one. I'll leave this open though since this specific instance has a potential fix associated with it.

@MartinJohns
Copy link
Contributor

Your potential fix has been rejected before already: #53904 (comment)

The proposed signature allows any argument, which we consider to be too loose

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jun 24, 2024
@RyanCavanaugh RyanCavanaugh closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants