mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 10:12:42 +03:00
fix(es/compat): Visit transformed expression in optional chaining pass (#7614)
**Related issue:** - Closes #7612.
This commit is contained in:
parent
984fdc8ef5
commit
c087c82aa3
19
crates/swc/tests/fixture/issues-7xxx/7612/input/.swcrc
Normal file
19
crates/swc/tests/fixture/issues-7xxx/7612/input/.swcrc
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"jsc": {
|
||||||
|
"parser": {
|
||||||
|
"syntax": "typescript",
|
||||||
|
"tsx": true
|
||||||
|
},
|
||||||
|
"target": "es5",
|
||||||
|
"loose": false,
|
||||||
|
"minify": {
|
||||||
|
"compress": false,
|
||||||
|
"mangle": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"module": {
|
||||||
|
"type": "es6"
|
||||||
|
},
|
||||||
|
"minify": false,
|
||||||
|
"isModule": true
|
||||||
|
}
|
1
crates/swc/tests/fixture/issues-7xxx/7612/input/1.js
Normal file
1
crates/swc/tests/fixture/issues-7xxx/7612/input/1.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
(qcData?.flawImageList || [])?.map()
|
2
crates/swc/tests/fixture/issues-7xxx/7612/output/1.js
Normal file
2
crates/swc/tests/fixture/issues-7xxx/7612/output/1.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var _this, _qcData;
|
||||||
|
(_this = ((_qcData = qcData) === null || _qcData === void 0 ? void 0 : _qcData.flawImageList) || []) === null || _this === void 0 ? void 0 : _this.map();
|
@ -1,5 +1,5 @@
|
|||||||
//// [deleteChain.ts]
|
//// [deleteChain.ts]
|
||||||
var _o1, _o11, _o2, _o21, _o3_b, _o3_b1, _o4_b_c_d, _o4_b, _this, _o4_b_c_d1, _o4_b1, _o5_b_c_d, _o5_b, _o5, _o5_b_c_d1, _o5_b1, _o51, _o6_b_c_d, _o6_b, _o6_b_c_d1, _o6_b1;
|
var _o1, _o11, _o2, _o21, _o3_b, _o3_b1, _o4_b_c_d, _o4_b, _this, _o4_b1, _o4_b_c_d1, _o4_b2, _o5_b_c_d, _o5_b, _o5, _o5_b_c_d1, _o5_b1, _o51, _o6_b_c_d, _o6_b, _o6_b_c_d1, _o6_b1;
|
||||||
(_o1 = o1) === null || _o1 === void 0 ? true : delete _o1.b;
|
(_o1 = o1) === null || _o1 === void 0 ? true : delete _o1.b;
|
||||||
delete ((_o11 = o1) === null || _o11 === void 0 ? void 0 : _o11.b);
|
delete ((_o11 = o1) === null || _o11 === void 0 ? void 0 : _o11.b);
|
||||||
(_o2 = o2) === null || _o2 === void 0 ? true : delete _o2.b.c;
|
(_o2 = o2) === null || _o2 === void 0 ? true : delete _o2.b.c;
|
||||||
@ -7,8 +7,8 @@ delete ((_o21 = o2) === null || _o21 === void 0 ? void 0 : _o21.b.c);
|
|||||||
(_o3_b = o3.b) === null || _o3_b === void 0 ? true : delete _o3_b.c;
|
(_o3_b = o3.b) === null || _o3_b === void 0 ? true : delete _o3_b.c;
|
||||||
delete ((_o3_b1 = o3.b) === null || _o3_b1 === void 0 ? void 0 : _o3_b1.c);
|
delete ((_o3_b1 = o3.b) === null || _o3_b1 === void 0 ? void 0 : _o3_b1.c);
|
||||||
(_o4_b = o4.b) === null || _o4_b === void 0 ? true : (_o4_b_c_d = _o4_b.c.d) === null || _o4_b_c_d === void 0 ? true : delete _o4_b_c_d.e;
|
(_o4_b = o4.b) === null || _o4_b === void 0 ? true : (_o4_b_c_d = _o4_b.c.d) === null || _o4_b_c_d === void 0 ? true : delete _o4_b_c_d.e;
|
||||||
(_this = (o4.b?.c.d)) === null || _this === void 0 ? true : delete _this.e;
|
(_this = (_o4_b1 = o4.b) === null || _o4_b1 === void 0 ? void 0 : _o4_b1.c.d) === null || _this === void 0 ? true : delete _this.e;
|
||||||
delete ((_o4_b1 = o4.b) === null || _o4_b1 === void 0 ? void 0 : (_o4_b_c_d1 = _o4_b1.c.d) === null || _o4_b_c_d1 === void 0 ? void 0 : _o4_b_c_d1.e);
|
delete ((_o4_b2 = o4.b) === null || _o4_b2 === void 0 ? void 0 : (_o4_b_c_d1 = _o4_b2.c.d) === null || _o4_b_c_d1 === void 0 ? void 0 : _o4_b_c_d1.e);
|
||||||
(_o5_b = (_o5 = o5).b) === null || _o5_b === void 0 ? true : (_o5_b_c_d = _o5_b.call(_o5).c.d) === null || _o5_b_c_d === void 0 ? true : delete _o5_b_c_d.e;
|
(_o5_b = (_o5 = o5).b) === null || _o5_b === void 0 ? true : (_o5_b_c_d = _o5_b.call(_o5).c.d) === null || _o5_b_c_d === void 0 ? true : delete _o5_b_c_d.e;
|
||||||
delete ((_o5_b1 = (_o51 = o5).b) === null || _o5_b1 === void 0 ? void 0 : (_o5_b_c_d1 = _o5_b1.call(_o51).c.d) === null || _o5_b_c_d1 === void 0 ? void 0 : _o5_b_c_d1.e);
|
delete ((_o5_b1 = (_o51 = o5).b) === null || _o5_b1 === void 0 ? void 0 : (_o5_b_c_d1 = _o5_b1.call(_o51).c.d) === null || _o5_b_c_d1 === void 0 ? void 0 : _o5_b_c_d1.e);
|
||||||
(_o6_b = o6.b) === null || _o6_b === void 0 ? true : (_o6_b_c_d = _o6_b["c"].d) === null || _o6_b_c_d === void 0 ? true : delete _o6_b_c_d["e"];
|
(_o6_b = o6.b) === null || _o6_b === void 0 ? true : (_o6_b_c_d = _o6_b["c"].d) === null || _o6_b_c_d === void 0 ? true : delete _o6_b_c_d["e"];
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
//// [deleteChain.ts]
|
//// [deleteChain.ts]
|
||||||
var _o1, _o11, _o2, _o21, _o3_b, _o3_b1, _o4_b_c_d, _o4_b, _this, _o4_b_c_d1, _o4_b1, _o5_b_c_d, _o5_b, _o5, _o5_b_c_d1, _o5_b1, _o51, _o6_b_c_d, _o6_b, _o6_b_c_d1, _o6_b1;
|
var _o1, _o11, _o2, _o21, _o3_b, _o3_b1, _o4_b_c_d, _o4_b, _this, _o4_b1, _o4_b_c_d1, _o4_b2, _o5_b_c_d, _o5_b, _o5, _o5_b_c_d1, _o5_b1, _o51, _o6_b_c_d, _o6_b, _o6_b_c_d1, _o6_b1;
|
||||||
null === (_o1 = o1) || void 0 === _o1 || delete _o1.b, delete (null === (_o11 = o1) || void 0 === _o11 ? void 0 : _o11.b), null === (_o2 = o2) || void 0 === _o2 || delete _o2.b.c, delete (null === (_o21 = o2) || void 0 === _o21 ? void 0 : _o21.b.c), null === (_o3_b = o3.b) || void 0 === _o3_b || delete _o3_b.c, delete (null === (_o3_b1 = o3.b) || void 0 === _o3_b1 ? void 0 : _o3_b1.c), null === (_o4_b = o4.b) || void 0 === _o4_b || null === (_o4_b_c_d = _o4_b.c.d) || void 0 === _o4_b_c_d || delete _o4_b_c_d.e, null === (_this = o4.b?.c.d) || void 0 === _this || delete _this.e, delete (null === (_o4_b1 = o4.b) || void 0 === _o4_b1 ? void 0 : null === (_o4_b_c_d1 = _o4_b1.c.d) || void 0 === _o4_b_c_d1 ? void 0 : _o4_b_c_d1.e), null === (_o5_b = (_o5 = o5).b) || void 0 === _o5_b || null === (_o5_b_c_d = _o5_b.call(_o5).c.d) || void 0 === _o5_b_c_d || delete _o5_b_c_d.e, delete (null === (_o5_b1 = (_o51 = o5).b) || void 0 === _o5_b1 ? void 0 : null === (_o5_b_c_d1 = _o5_b1.call(_o51).c.d) || void 0 === _o5_b_c_d1 ? void 0 : _o5_b_c_d1.e), null === (_o6_b = o6.b) || void 0 === _o6_b || null === (_o6_b_c_d = _o6_b.c.d) || void 0 === _o6_b_c_d || delete _o6_b_c_d.e, delete (null === (_o6_b1 = o6.b) || void 0 === _o6_b1 ? void 0 : null === (_o6_b_c_d1 = _o6_b1.c.d) || void 0 === _o6_b_c_d1 ? void 0 : _o6_b_c_d1.e);
|
null === (_o1 = o1) || void 0 === _o1 || delete _o1.b, delete (null === (_o11 = o1) || void 0 === _o11 ? void 0 : _o11.b), null === (_o2 = o2) || void 0 === _o2 || delete _o2.b.c, delete (null === (_o21 = o2) || void 0 === _o21 ? void 0 : _o21.b.c), null === (_o3_b = o3.b) || void 0 === _o3_b || delete _o3_b.c, delete (null === (_o3_b1 = o3.b) || void 0 === _o3_b1 ? void 0 : _o3_b1.c), null === (_o4_b = o4.b) || void 0 === _o4_b || null === (_o4_b_c_d = _o4_b.c.d) || void 0 === _o4_b_c_d || delete _o4_b_c_d.e, null === (_this = null === (_o4_b1 = o4.b) || void 0 === _o4_b1 ? void 0 : _o4_b1.c.d) || void 0 === _this || delete _this.e, delete (null === (_o4_b2 = o4.b) || void 0 === _o4_b2 ? void 0 : null === (_o4_b_c_d1 = _o4_b2.c.d) || void 0 === _o4_b_c_d1 ? void 0 : _o4_b_c_d1.e), null === (_o5_b = (_o5 = o5).b) || void 0 === _o5_b || null === (_o5_b_c_d = _o5_b.call(_o5).c.d) || void 0 === _o5_b_c_d || delete _o5_b_c_d.e, delete (null === (_o5_b1 = (_o51 = o5).b) || void 0 === _o5_b1 ? void 0 : null === (_o5_b_c_d1 = _o5_b1.call(_o51).c.d) || void 0 === _o5_b_c_d1 ? void 0 : _o5_b_c_d1.e), null === (_o6_b = o6.b) || void 0 === _o6_b || null === (_o6_b_c_d = _o6_b.c.d) || void 0 === _o6_b_c_d || delete _o6_b_c_d.e, delete (null === (_o6_b1 = o6.b) || void 0 === _o6_b1 ? void 0 : null === (_o6_b_c_d1 = _o6_b1.c.d) || void 0 === _o6_b_c_d1 ? void 0 : _o6_b_c_d1.e);
|
||||||
|
@ -203,7 +203,10 @@ impl OptChaining {
|
|||||||
Expr::OptChain(next) => {
|
Expr::OptChain(next) => {
|
||||||
current = next;
|
current = next;
|
||||||
}
|
}
|
||||||
base => return (base, count, chain),
|
mut base => {
|
||||||
|
base.visit_mut_children_with(self);
|
||||||
|
return (base, count, chain);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
var _foo, _a_b_c, _a, _a_b_c_d, _a_b, _a_b_c_d1, _a_b_c1, _orders, _orders_, _orders1, _client, _orders_client_key, _a1, _c;
|
var _foo, _a_b_c, _a, _a_b_c_d, _a_b, _a_b_c_d1, _a_b_c1, _orders, _orders_, _orders1, _client, _orders_client_key, _a1, _c, _a2;
|
||||||
(_foo = foo) === null || _foo === void 0 ? void 0 : _foo.bar;
|
(_foo = foo) === null || _foo === void 0 ? void 0 : _foo.bar;
|
||||||
(_a = a) === null || _a === void 0 ? void 0 : (_a_b_c = _a.b.c) === null || _a_b_c === void 0 ? void 0 : _a_b_c.d.e;
|
(_a = a) === null || _a === void 0 ? void 0 : (_a_b_c = _a.b.c) === null || _a_b_c === void 0 ? void 0 : _a_b_c.d.e;
|
||||||
(_a_b = a.b) === null || _a_b === void 0 ? void 0 : (_a_b_c_d = _a_b.c.d) === null || _a_b_c_d === void 0 ? void 0 : _a_b_c_d.e;
|
(_a_b = a.b) === null || _a_b === void 0 ? void 0 : (_a_b_c_d = _a_b.c.d) === null || _a_b_c_d === void 0 ? void 0 : _a_b_c_d.e;
|
||||||
@ -8,4 +8,4 @@ var _foo, _a_b_c, _a, _a_b_c_d, _a_b, _a_b_c_d1, _a_b_c1, _orders, _orders_, _or
|
|||||||
orders[(_client = client) === null || _client === void 0 ? void 0 : _client.key].price;
|
orders[(_client = client) === null || _client === void 0 ? void 0 : _client.key].price;
|
||||||
(_orders_client_key = orders[client.key]) === null || _orders_client_key === void 0 ? void 0 : _orders_client_key.price;
|
(_orders_client_key = orders[client.key]) === null || _orders_client_key === void 0 ? void 0 : _orders_client_key.price;
|
||||||
(0, (_a1 = a) === null || _a1 === void 0 ? void 0 : _a1.b).c;
|
(0, (_a1 = a) === null || _a1 === void 0 ? void 0 : _a1.b).c;
|
||||||
(0, (_c = (0, a?.b).c) === null || _c === void 0 ? void 0 : _c.d).e;
|
(0, (_c = (0, (_a2 = a) === null || _a2 === void 0 ? void 0 : _a2.b).c) === null || _c === void 0 ? void 0 : _c.d).e;
|
||||||
|
Loading…
Reference in New Issue
Block a user