-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
Has PRSpec: Object Rest/SpreadoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
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 } } } = defunctBabel 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 |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Has PRSpec: Object Rest/SpreadoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue