Skip to content

Array.prototype.flat definitions are inaccurate #29741

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

Closed
shicks opened this issue Feb 5, 2019 · 3 comments
Closed

Array.prototype.flat definitions are inaccurate #29741

shicks opened this issue Feb 5, 2019 · 3 comments

Comments

@shicks
Copy link
Contributor

shicks commented Feb 5, 2019

Code

const x = [1, [[2]]];
const y: never = x.flat();

Expected behavior:
I expect the following error:

Type '(1 | [2])[]' is not assignable to type 'never'.

or with more general types,

Type '(number | number[])[]' is not assignable to type 'never'.

This should actually be pretty easy to implement by simply unwrapping the array type (see link below).

Actual behavior:
I instead see

Type 'any[]' is not assignable to type 'never'.

Playground Link:
Using the current definitions
What I expect should happen

Related Issues:
None found.

@RyanCavanaugh
Copy link
Member

Duplicate #29604 or at least just another case we should consider there when examining its definition

@RyanCavanaugh
Copy link
Member

Related Issues: None found.

👁👁

@shicks
Copy link
Contributor Author

shicks commented Feb 5, 2019

I searched [Array flat definition] - apparently I should have left off "definition".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants