Using spread on an object method generates breaking syntax
- Dominant language
- JavaScript
- Stars
- 874
- Forks
- 62
- PR merge metrics
- No merged PRs in 30d
Description
Here's a minimal representation of the original code, which works well on the browser:
```js
const foo = { bar: [] }
const baz = true ? [1,2,3] : []
foo.bar.push(...baz)
// [1,2,3]
console.log(foo.bar)
```
When transpiled, the entire push operation appears to be ignored.
```js
var foo = { bar: [] }
var baz = true ? [1,2,3] : []
(ref = foo.bar).push.apply(ref, [1,2,3])
// []
console.log(foo.bar)
var ref;
```
The current workaround is to add `;` at the end of the ternary, breaking off the second and third line:
```js
const foo = { bar: [] }
const baz = true ? [1,2,3] : [];
foo.bar.push(...baz)
// [1,2,3]
console.log(foo.bar)
```
Buble should automatically add the `;` because it added the parens. The consumer should not be aware about adding `;` due to implementation, especially when the code works without it before transpilation.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.