Closed
Description
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.