object-rest-spread
works standalone and a few new plugin options APIs were added!
v6.19.0 Summary (2016-11-16)
🚀 New Feature
#4755 Make object-rest-spread
work as an independent plugin. (@hzoo)
This rewrite fixes a long standing issue where the object-rest-spread
plugin was depending on 2 other plugins to compile RestProperty
properly.
This fix important given the assumption that plugins should be independent and is vital for the use of babel-preset-env since new environments support destructuring natively.
In
JavaScript
const { a, ...b } = c;
Out
JavaScript
const { a } = c; // remove the `...b`
const b = _objectWithoutProperties(c, ["a"]); // use the helper
It's interesting to see all the places where you can destructure!
RestProperty
function a({ b, ...c }) {} // Parameters
JavaScript
const { a, ...b } = c; // VariableDeclaration
JavaScript
export var { a, ...b } = c; // ExportNamedDeclaration
JavaScript
try {} catch ({a, ...b}) {} // CatchClause
JavaScript
({a, ...b} = c); // AssignmentExpression
JavaScript
for ({a, ...b} of []) {} // ForXStatement
SpreadProperty
JavaScript
var a = { ...b, ...c } // ObjectExpression