mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
fix(traverse): handle ChainElement::TSNonNullExpression in GatherNodeParts (#22247)
Fixes #22246, transformer panics with `const x = a[b?.c!]?.["d"];` under es2020 target. (I wasn't sure where to put the test, but I've confirmed that it works on my end for now.)
This commit is contained in:
1 parent
ca8fb74d8d
commit
d3d0b18fde
4 files changed
+14
-2
No files matched your search
@@ -234,7 +234,8 @@ impl<'a> GatherNodeParts<'a> for ChainElement<'a> {
|
||||
fn gather<F: FnMut(&str)>(&self, f: &mut F) {
|
||||
match self {
|
||||
ChainElement::CallExpression(expr) => expr.gather(f),
|
||||
expr => expr.to_member_expression().gather(f),
|
||||
ChainElement::TSNonNullExpression(expr) => expr.expression.gather(f),
|
||||
expr @ match_member_expression!(Self) => expr.to_member_expression().gather(f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
commit: 6402dbbf
|
||||
|
||||
Passed: 231/379
|
||||
Passed: 232/380
|
||||
|
||||
# All Passed:
|
||||
* babel-plugin-transform-class-static-block
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// Panicked when transforming optional chaining with TS non-null assertion inside a computed key.
|
||||
// https://github.com/oxc-project/oxc/issues/22246
|
||||
const x = a[b?.c!]?.["d"];
|
||||
const y = a?.[b?.c!]?.d;
|
||||
const z = a[b?.c!.d!]?.e;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// Panicked when transforming optional chaining with TS non-null assertion inside a computed key.
|
||||
// https://github.com/oxc-project/oxc/issues/22246
|
||||
var _a$b$c, _b, _a, _b2, _a$d, _b3;
|
||||
const x = (_a$b$c = a[(_b = b) === null || _b === void 0 ? void 0 : _b.c]) === null || _a$b$c === void 0 ? void 0 : _a$b$c["d"];
|
||||
const y = (_a = a) === null || _a === void 0 || (_a = _a[(_b2 = b) === null || _b2 === void 0 ? void 0 : _b2.c]) === null || _a === void 0 ? void 0 : _a.d;
|
||||
const z = (_a$d = a[(_b3 = b) === null || _b3 === void 0 ? void 0 : _b3.c.d]) === null || _a$d === void 0 ? void 0 : _a$d.e;
|
||||
Reference in new issue
Block a user