Skip to content

Array(n) is spreaded incorrectly in arrays #14088

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
zuzusik opened this issue Feb 15, 2017 · 4 comments
Closed

Array(n) is spreaded incorrectly in arrays #14088

zuzusik opened this issue Feb 15, 2017 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@zuzusik
Copy link

zuzusik commented Feb 15, 2017

TypeScript Version: 2.1.6

Code

[...Array(5)]

Expected behavior:
Array filled with undefined 5 times (this is how it should be by the spec and how Chrome/FF/Safari do it)

Actual behavior:
Empty array with length set to 5

@alex3165
Copy link

Typescript compile it to Array(5).slice(); https://www.typescriptlang.org/play/#src=%5B...Array(5)%5D%0D%0A

@zuzusik
Copy link
Author

zuzusik commented Feb 15, 2017

@alex3165 yes, it does, and this is wrong because it gives non spec compliant result

@alex3165
Copy link

@zuzusik Agreed, it is not really expected

@zuzusik zuzusik changed the title Array spreads Array(n) incorrectly Array(n) is spreaded incorrectly in arrays Feb 15, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Feb 15, 2017

Duplicate of #8856

@mhegazy mhegazy added the Duplicate An existing issue was already created label Feb 15, 2017
@mhegazy mhegazy closed this as completed Apr 19, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants