Choose one: is this a bug report or feature request?
Bug
Input Code
https://github.com/daerion/babel-rest-spread-bug
const defunct = {
outer: {
inner: {
three: 'three',
four: 'four'
}
}
}
const { outer: { inner: { three, ...other } } } = defunct
Babel Configuration (.babelrc, package.json, cli command)
{
"plugins": [
[ "transform-object-rest-spread" ]
]
}
Expected Behavior
Using the above example, two constants should be assigned:
console.log('three: %s', three) // 'three'
console.dir(other) // { four: 'four' }
Or, more explicitly, other should be an object containing all values from defunct.outer.inner except for three.
Current Behavior
Transpiling the above code results in the following (declarations omitted for brevity, see repository linked above for full source):
const { outer: { inner: { three } } } = defunct,
other = _objectWithoutProperties(defunct.inner.outer, ['three']);
I.e. instead of constructing other from defunct.outer.inner, babel will attempt to use defunct.inner.outer, which is undefined. This happens also when nesting objects even further (again, see linked repo).
Your Environment
| software |
version(s) |
| Babel |
6.24.1 |
| transform-object-rest-spread |
6.23.0 |
| node |
7.9.0 and 6.10.2 |
| npm |
4.2.0 and 3.10.10 |
| Operating System |
Ubuntu 16.10 |
Choose one: is this a bug report or feature request?
Bug
Input Code
https://github.com/daerion/babel-rest-spread-bug
Babel Configuration (.babelrc, package.json, cli command)
Expected Behavior
Using the above example, two constants should be assigned:
Or, more explicitly,
othershould be an object containing all values fromdefunct.outer.innerexcept forthree.Current Behavior
Transpiling the above code results in the following (declarations omitted for brevity, see repository linked above for full source):
I.e. instead of constructing
otherfromdefunct.outer.inner, babel will attempt to usedefunct.inner.outer, which is undefined. This happens also when nesting objects even further (again, see linked repo).Your Environment
6.24.16.23.07.9.0and6.10.24.2.0and3.10.10