Skip to content

Commit ab8df21

Browse files
authored
Fix optional chaining in argument position (#1104)
1 parent a9c3072 commit ab8df21

File tree

11 files changed

+34
-4
lines changed

11 files changed

+34
-4
lines changed

ecmascript/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2018"
66
license = "Apache-2.0/MIT"
77
name = "swc_ecmascript"
88
repository = "https://github.com/swc-project/swc.git"
9-
version = "0.8.1"
9+
version = "0.8.2"
1010

1111
[features]
1212
codegen = ["swc_ecma_codegen"]

ecmascript/transforms/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2018"
66
license = "Apache-2.0/MIT"
77
name = "swc_ecma_transforms"
88
repository = "https://github.com/swc-project/swc.git"
9-
version = "0.24.1"
9+
version = "0.24.2"
1010

1111
[features]
1212
const-modules = ["dashmap"]

ecmascript/transforms/src/compat/es2020/opt_chaining.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ impl OptChaining {
159159
})),
160160
..expr
161161
}),
162-
Err(e) => e,
162+
Err(callee) => Expr::Call(CallExpr {
163+
callee: callee.as_callee(),
164+
..e
165+
}),
163166
};
164167
}
165168
_ => {}

ecmascript/transforms/tests/es2020_optional_chaining.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,3 +614,30 @@ test_exec!(
614614
expect(obj?.a?.b?.c()).toBe(2)
615615
"
616616
);
617+
618+
test!(
619+
syntax(),
620+
|_| tr(()),
621+
swc_node_95_2,
622+
"
623+
obj?.a?.b?.c()
624+
",
625+
"
626+
var ref, ref1;
627+
obj === null || obj === void 0 ? void 0 : (ref = obj.a) === null || ref === void 0 ? void 0 : \
628+
(ref1 = ref.b) === null || ref1 === void 0 ? void 0 : ref1.c();"
629+
);
630+
631+
test!(
632+
syntax(),
633+
|_| tr(()),
634+
swc_node_95_3,
635+
"
636+
expect(obj?.a?.b?.c()).toBe(2)
637+
",
638+
"
639+
var ref, ref1;
640+
expect(obj === null || obj === void 0 ? void 0 : (ref = obj.a) === null || ref === void 0 ? void 0 \
641+
: (ref1 = ref.b) === null || ref1 === void 0 ? void 0 : ref1.c()).toBe(2);
642+
"
643+
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@swc/core",
3-
"version": "1.2.32",
3+
"version": "1.2.33",
44
"description": "Super-fast alternative for babel",
55
"homepage": "https://swc.rs",
66
"main": "./index.js",

0 commit comments

Comments
 (0)