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
const { a, ...b } = c;
Out
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
const { a, ...b } = c; // VariableDeclaration
export var { a, ...b } = c; // ExportNamedDeclaration
try {} catch ({a, ...b}) {} // CatchClause
({a, ...b} = c); // AssignmentExpression
for ({a, ...b} of []) {} // ForXStatement
SpreadProperty
var a = { ...b, ...c } // ObjectExpression
#4544 Add the spec
option to "transform-class-properties"
. (@motiz88)
Class properties will use Object.defineProperty
instead of a simple this.x = y
.
Static fields are will use value: undefined
even if they are not initialized.
Usage
{
"plugins": [
["transform-class-properties", {
"spec": true
}]
]
}
In
class Foo {
static bar;
baz = 'guy';
}
Out
var Foo = function Foo() {
_classCallCheck(this, Foo);
this.baz = 'guy';
};