bublejs / buble

https://buble.surge.sh
MIT License
869 stars 67 forks source link

Spread array with empty elements #238

Closed Th0rN13 closed 4 years ago

Th0rN13 commented 4 years ago

[...Array(3)] compiles into [].concat( Array(3) ) But [...Array(3)] - create array with 3 undefined elements, then [].concat( Array(3) ) create array with empty elements (array with empty elements cannot be iterated via map, forEach, etc.)

So [...Array(3)].map((_, i) => i) create array [0, 1, 2], but compiled [].concat( Array(3) ).map((_, i) => i) create empty array

Also some issue with sparse array - spread convert empty elements to undefined

mourner commented 4 years ago

Yep, duplicate of #81