Ensure destructuring's computed key handling matches object-rest-spread (#8793)
This commit is contained in:
@@ -6,7 +6,7 @@ var _z2 = z,
|
||||
y = babelHelpers.objectWithoutProperties(_z2, ["x"]);
|
||||
var _z3 = z,
|
||||
x = _z3[x],
|
||||
y = babelHelpers.objectWithoutProperties(_z3, [x]);
|
||||
y = babelHelpers.objectWithoutProperties(_z3, [x].map(babelHelpers.toPropertyKey));
|
||||
|
||||
(function (_ref) {
|
||||
var x = _ref.x,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
function _toPropertyKey(key) { if (typeof key === "symbol") { return key; } else { return String(key); } }
|
||||
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
||||
|
||||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
@@ -13,7 +15,7 @@ var _z2 = z,
|
||||
|
||||
var _z3 = z,
|
||||
x = _z3[x],
|
||||
y = _objectWithoutPropertiesLoose(_z3, [x]);
|
||||
y = _objectWithoutPropertiesLoose(_z3, [x].map(_toPropertyKey));
|
||||
|
||||
(function (_ref) {
|
||||
let x = _ref.x,
|
||||
|
||||
@@ -6,7 +6,7 @@ var _z2 = z,
|
||||
y = babelHelpers.objectWithoutProperties(_z2, ["x"]);
|
||||
var _z3 = z,
|
||||
x = _z3[x],
|
||||
y = babelHelpers.objectWithoutProperties(_z3, [x]);
|
||||
y = babelHelpers.objectWithoutProperties(_z3, [x].map(babelHelpers.toPropertyKey));
|
||||
|
||||
(function (_ref) {
|
||||
var x = _ref.x,
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
const { [(() => 1)()]: a, ...rest } = { 1: "a" };
|
||||
|
||||
expect(a).toBe("a");
|
||||
expect(rest).toEqual({});
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["transform-destructuring", "proposal-object-rest-spread"]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
const foo = {
|
||||
1: "a",
|
||||
2: "b",
|
||||
3: "c",
|
||||
};
|
||||
|
||||
const { [1]: bar, ...rest } = foo;
|
||||
|
||||
expect(bar).toBe("a");
|
||||
expect(rest).toEqual({ 2: "b", 3: "c" });
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["transform-destructuring", "proposal-object-rest-spread"]
|
||||
}
|
||||
Reference in New Issue
Block a user