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

Spread arrays #237

Closed
RyanCavanaugh opened this issue Jul 24, 2014 · 2 comments
Closed

Spread arrays #237

RyanCavanaugh opened this issue Jul 24, 2014 · 2 comments
Labels
Committed The team has roadmapped this issue ES6 Relates to the ES6 Spec Fixed A PR has been merged for this issue

Comments

@RyanCavanaugh
Copy link
Member

Example from ES6

[1, 2, ...items, 3, ...moreItems]

Type checking

The type of the array is the best common type of the individual elements and the element types of each of the "spread" elements.

Codegen

[1, 2, ...items, 3, ...moreItems]

becomes:

[1,2].concat(items, [3], moreItems)

If the array starts with a spread, you can concat off the spread:

[...items, 1, 2, ...moreItems]

becomes:

items.concat([1, 2], moreItems)

Questions

What if it's 'any'?  We don't know, so we have to codegen a slice. One possible issue is that .concat doesn't take array-like, it takes arrays only.  This won't be a problem for spread arguments because .apply should take array-likes.

@Arnavion
Copy link
Contributor

Fixed by #1463 ?

@RyanCavanaugh RyanCavanaugh added Committed The team has roadmapped this issue Fixed A PR has been merged for this issue and removed Needs More Info The issue still hasn't been fully clarified Suggestion An idea for TypeScript labels Dec 30, 2014
@RyanCavanaugh
Copy link
Member Author

Indeed!

@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Committed The team has roadmapped this issue ES6 Relates to the ES6 Spec Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

2 participants