Hoist omitted keys from object spread operator (#13384)

This commit is contained in:
Alan Orozco
2021-05-28 09:32:30 -07:00
committed by GitHub
parent 612f19fbdc
commit f35513fbaa
21 changed files with 110 additions and 35 deletions

View File

@@ -1,3 +1,5 @@
const _excluded = ["excluded", "excluded2", "used", "used2"],
_excluded2 = ["unused"];
// should not remove when destructuring into existing bindings
var _c = c2;
({
@@ -12,12 +14,12 @@ function render() {
used,
used2: usedRenamed
} = _this$props,
props = babelHelpers.objectWithoutProperties(_this$props, ["excluded", "excluded2", "used", "used2"]);
props = babelHelpers.objectWithoutProperties(_this$props, _excluded);
console.log(used, usedRenamed);
return React.createElement("input", props);
}
function smth(_ref) {
let rest = babelHelpers.objectWithoutProperties(_ref, ["unused"]);
let rest = babelHelpers.objectWithoutProperties(_ref, _excluded2);
call(rest);
}

View File

@@ -1,3 +1,7 @@
const _excluded = ["a1"],
_excluded2 = ["a2", "b2"],
_excluded3 = ["c3"];
try {} catch (_ref) {
let a34 = babelHelpers.extends({}, _ref);
}
@@ -6,7 +10,7 @@ try {} catch (_ref2) {
let {
a1
} = _ref2,
b1 = babelHelpers.objectWithoutProperties(_ref2, ["a1"]);
b1 = babelHelpers.objectWithoutProperties(_ref2, _excluded);
}
try {} catch (_ref3) {
@@ -14,7 +18,7 @@ try {} catch (_ref3) {
a2,
b2
} = _ref3,
c2 = babelHelpers.objectWithoutProperties(_ref3, ["a2", "b2"]);
c2 = babelHelpers.objectWithoutProperties(_ref3, _excluded2);
}
try {} catch (_ref4) {
@@ -25,7 +29,7 @@ try {} catch (_ref4) {
c3
}
} = _ref4,
c4 = babelHelpers.objectWithoutProperties(_ref4.c2, ["c3"]);
c4 = babelHelpers.objectWithoutProperties(_ref4.c2, _excluded3);
} // Unchanged

View File

@@ -1,10 +1,14 @@
const _excluded = ["a"],
_excluded2 = ["a"],
_excluded3 = ["a"];
// ForXStatement
for (const _ref of []) {
const [_ref2] = _ref;
const {
a
} = _ref2,
b = babelHelpers.objectWithoutProperties(_ref2, ["a"]);
b = babelHelpers.objectWithoutProperties(_ref2, _excluded);
}
for (var _ref3 of []) {
@@ -12,7 +16,7 @@ for (var _ref3 of []) {
var {
a
} = _ref4,
b = babelHelpers.objectWithoutProperties(_ref4, ["a"]);
b = babelHelpers.objectWithoutProperties(_ref4, _excluded2);
}
async function a() {
@@ -21,7 +25,7 @@ async function a() {
var {
a
} = _ref6,
b = babelHelpers.objectWithoutProperties(_ref6, ["a"]);
b = babelHelpers.objectWithoutProperties(_ref6, _excluded3);
}
} // skip

View File

@@ -1,9 +1,11 @@
const _excluded = ["a"];
for (var _ref of []) {
var _ref2 = _ref;
({
a
} = _ref2);
b = babelHelpers.objectWithoutProperties(_ref2, ["a"]);
b = babelHelpers.objectWithoutProperties(_ref2, _excluded);
_ref2;
void 0;
}

View File

@@ -1,9 +1,13 @@
const _excluded = ["a"],
_excluded2 = ["a"],
_excluded3 = ["a"];
// ForXStatement
for (var _ref of []) {
var {
a
} = _ref,
b = babelHelpers.objectWithoutProperties(_ref, ["a"]);
b = babelHelpers.objectWithoutProperties(_ref, _excluded);
}
for (var _ref2 of []) {
@@ -11,7 +15,7 @@ for (var _ref2 of []) {
({
a
} = _ref3);
b = babelHelpers.objectWithoutProperties(_ref3, ["a"]);
b = babelHelpers.objectWithoutProperties(_ref3, _excluded2);
_ref3;
}
@@ -21,7 +25,7 @@ async function a() {
({
a
} = _ref5);
b = babelHelpers.objectWithoutProperties(_ref5, ["a"]);
b = babelHelpers.objectWithoutProperties(_ref5, _excluded3);
_ref5;
}
} // skip

View File

@@ -1,3 +1,5 @@
const _excluded = ["X"];
_ref => {
let R = babelHelpers.extends({}, _ref);
let a = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : R;
@@ -7,7 +9,7 @@ _ref => {
let {
X: Y
} = _ref2,
R = babelHelpers.objectWithoutProperties(_ref2, ["X"]);
R = babelHelpers.objectWithoutProperties(_ref2, _excluded);
let {
a = {
Y

View File

@@ -1,3 +1,13 @@
const _excluded = ["a1"],
_excluded2 = ["a2", "b2"],
_excluded3 = ["a5"],
_excluded4 = ["a3"],
_excluded5 = ["ba1"],
_excluded6 = ["a3", "b2"],
_excluded7 = ["ba1"],
_excluded8 = ["a1"],
_excluded9 = ["a1"];
function a(_ref) {
let a34 = babelHelpers.extends({}, _ref);
}
@@ -6,7 +16,7 @@ function a2(_ref2) {
let {
a1
} = _ref2,
b1 = babelHelpers.objectWithoutProperties(_ref2, ["a1"]);
b1 = babelHelpers.objectWithoutProperties(_ref2, _excluded);
}
function a3(_ref3) {
@@ -14,18 +24,18 @@ function a3(_ref3) {
a2,
b2
} = _ref3,
c2 = babelHelpers.objectWithoutProperties(_ref3, ["a2", "b2"]);
c2 = babelHelpers.objectWithoutProperties(_ref3, _excluded2);
}
function a4(_ref4, _ref5) {
let {
a5
} = _ref5,
c5 = babelHelpers.objectWithoutProperties(_ref5, ["a5"]);
c5 = babelHelpers.objectWithoutProperties(_ref5, _excluded3);
let {
a3
} = _ref4,
c3 = babelHelpers.objectWithoutProperties(_ref4, ["a3"]);
c3 = babelHelpers.objectWithoutProperties(_ref4, _excluded4);
}
function a5(_ref6) {
@@ -35,8 +45,8 @@ function a5(_ref6) {
ba1
}
} = _ref6,
ba2 = babelHelpers.objectWithoutProperties(_ref6.b2, ["ba1"]),
c3 = babelHelpers.objectWithoutProperties(_ref6, ["a3", "b2"]);
ba2 = babelHelpers.objectWithoutProperties(_ref6.b2, _excluded5),
c3 = babelHelpers.objectWithoutProperties(_ref6, _excluded6);
}
function a6(_ref7) {
@@ -46,14 +56,14 @@ function a6(_ref7) {
ba1
}
} = _ref7,
ba2 = babelHelpers.objectWithoutProperties(_ref7.b2, ["ba1"]);
ba2 = babelHelpers.objectWithoutProperties(_ref7.b2, _excluded7);
}
function a7(_ref8 = {}) {
let {
a1 = 1
} = _ref8,
b1 = babelHelpers.objectWithoutProperties(_ref8, ["a1"]);
b1 = babelHelpers.objectWithoutProperties(_ref8, _excluded8);
}
function a8([_ref9]) {
@@ -64,7 +74,7 @@ function a9([_ref10]) {
let {
a1
} = _ref10,
a2 = babelHelpers.objectWithoutProperties(_ref10, ["a1"]);
a2 = babelHelpers.objectWithoutProperties(_ref10, _excluded9);
}
function a10([a1, _ref11]) {

View File

@@ -1,3 +1,5 @@
const _excluded = ["excluded", "excluded2", "used", "used2"],
_excluded2 = ["unused"];
// should not remove when destructuring into existing bindings
var _c = c2;
({
@@ -13,7 +15,7 @@ class Comp extends React.Component {
used,
used2: usedRenamed
} = _this$props,
props = babelHelpers.objectWithoutPropertiesLoose(_this$props, ["excluded", "excluded2", "used", "used2"]);
props = babelHelpers.objectWithoutPropertiesLoose(_this$props, _excluded);
console.log(used, usedRenamed);
return React.createElement("input", props);
}
@@ -21,6 +23,6 @@ class Comp extends React.Component {
}
function smth(_ref) {
let rest = babelHelpers.objectWithoutPropertiesLoose(_ref, ["unused"]);
let rest = babelHelpers.objectWithoutPropertiesLoose(_ref, _excluded2);
call(rest);
}

View File

@@ -1,3 +1,5 @@
const _excluded = ["b"];
const _foo = foo(),
{
s
@@ -19,6 +21,6 @@ const {
let {
b
} = _ref,
c = babelHelpers.objectWithoutProperties(_ref, ["b"]);
c = babelHelpers.objectWithoutProperties(_ref, _excluded);
console.log(b, c);
});

View File

@@ -1,3 +1,5 @@
const _excluded = ["a"];
function fn0(obj0) {
const {
fn1 = (obj1 = {}) => {
@@ -6,7 +8,7 @@ function fn0(obj0) {
const {
a
} = obj2,
rest = babelHelpers.objectWithoutProperties(obj2, ["a"]);
rest = babelHelpers.objectWithoutProperties(obj2, _excluded);
console.log(rest);
}
} = obj1;

View File

@@ -1,3 +1,5 @@
const _excluded = ["a", "b", "c"];
const get = () => {
fireTheMissiles();
return 3;
@@ -8,6 +10,6 @@ const f = _ref => {
a = get(),
b
} = _ref,
z = babelHelpers.objectWithoutPropertiesLoose(_ref, ["a", "b", "c"]);
z = babelHelpers.objectWithoutPropertiesLoose(_ref, _excluded);
const v = b + 3;
};