babel: Object rest spread not working correctly in object destructuring (T7086)
Issue originally made by @xinchaobeta
Bug information
- Babel version: 6.4.5
- Node version: v4.1.0
- npm version: 2.14.3
Options
{
"plugins": ["transform-object-rest-spread"]
}
Input code
let {a, b, ...c} = d
Description
the output code is
let { a, b, ...c } = d;
we expect
let {a, b} = d
let c = _objectWithoutProperties(d, ["a", "b"]);
In the above example, we have not include the es2015-destructuring , because we only want compile es7 to es6
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 23 (11 by maintainers)
Commits related to this issue
- object rest spread now well supported https://github.com/babel/babel/issues/4074 has been handled in `babel-plugin-transform-object-rest-spread`. As of https://github.com/babel/babel/releases/tag/v6.... — committed to rgbkrk/babel-preset-es2015-node6 by rgbkrk 8 years ago
- object rest spread now well supported (#9) https://github.com/babel/babel/issues/4074 has been handled in `babel-plugin-transform-object-rest-spread`. As of https://github.com/babel/babel/releases/ta... — committed to jhen0409/babel-preset-es2015-node6 by rgbkrk 8 years ago
Since is this high priority + (given I’m working on https://github.com/babel/babel-preset-env and having to whitelist the destructuring/parameter transforms if using object spread sucks), I’m going to work on this.
Ok the PR is https://github.com/babel/babel/pull/4755
Can folks try the changes locally and report back?
Can test locally by replacing in node_modules: https://gist.github.com/hzoo/d269ccfd5758c556c900f47dd752cd61 - I just took the code that changed in
src
and ran it in the babel repl in loose modereplace
node_modules/babel-plugin-transform-object-rest-spread/lib/index.js
Just Note:
babel-plugin-transform-es2015-spread
,babel-plugin-transform-es2015-parameters
andbabel-plugin-transform-es2015-destructuring
are required, if we write code like below:Tested in Node 6 with babel@6