Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/oxc_transformer/src/es2020/optional_chaining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ impl<'a> OptionalChaining<'a, '_> {
// If this chain expression is a callee of a CallExpression, we need to transform it to accept a proper context
// `(Foo?.["m"])();` -> `(... _Foo["m"].bind(_Foo))();`
// ^^^^^^^^^^^ Here we will handle the `right` part to bind a proper context
if matches!(ctx.ancestor(1), Ancestor::CallExpressionCallee(_)) {
if ctx.parent().is_parenthesized_expression()
&& matches!(ctx.ancestor(1), Ancestor::CallExpressionCallee(_))
{
chain_expr = self.transform_expression_to_bind_context(chain_expr, ctx);
}
// Clear states
Expand Down
2 changes: 1 addition & 1 deletion tasks/transform_conformance/snapshots/oxc.snap.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
commit: 1d4546bc

Passed: 153/257
Passed: 154/258

# All Passed:
* babel-plugin-transform-class-static-block
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const a = {}

call(a?.b)(a?.c)
call((a?.b))((a?.c))
call(a?.b())(a?.c())
call((a?.b()))((a?.c()))
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const a = {};
call(a === null || a === void 0 ? void 0 : a.b)(a === null || a === void 0 ? void 0 : a.c);
call(a === null || a === void 0 ? void 0 : a.b)(a === null || a === void 0 ? void 0 : a.c);
call(a === null || a === void 0 ? void 0 : a.b())(a === null || a === void 0 ? void 0 : a.c());
call(a === null || a === void 0 ? void 0 : a.b())(a === null || a === void 0 ? void 0 : a.c());
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["transform-optional-chaining"]
}
Loading