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
15 changes: 12 additions & 3 deletions crates/oxc_transformer/src/es2022/class_properties/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,7 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {

let is_optional = field_expr.optional;
let object = &mut field_expr.object;

let left = if is_optional {
Some(self.transform_expression_to_wrap_nullish_check(object, ctx))
} else {
Expand Down Expand Up @@ -1192,9 +1193,17 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
object: &mut Expression<'a>,
ctx: &mut TraverseCtx<'a>,
) -> Expression<'a> {
let owned_object = ctx.ast.move_expression(object.get_inner_expression_mut());
let owned_object =
Self::ensure_optional_expression_wrapped_by_chain_expression(owned_object, ctx);
let mut owned_object = ctx.ast.move_expression(object.get_inner_expression_mut());

let owned_object = if let Some(result) =
self.transform_chain_element_recursively(&mut owned_object, ctx)
{
// If the `object` contains PrivateFieldExpression, we need to transform it first.
Self::wrap_conditional_check(result, owned_object, ctx)
} else {
Self::ensure_optional_expression_wrapped_by_chain_expression(owned_object, ctx)
};

let (assignment, reference1, reference2) = self.duplicate_object_twice(owned_object, ctx);
*object = reference1;
self.wrap_nullish_check(assignment, reference2, ctx)
Expand Down
10 changes: 2 additions & 8 deletions tasks/transform_conformance/snapshots/babel.snap.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
commit: 54a8389f

Passed: 480/846
Passed: 482/846

# All Passed:
* babel-plugin-transform-class-static-block
Expand Down Expand Up @@ -276,7 +276,7 @@ x Output mismatch
x Output mismatch


# babel-plugin-transform-class-properties (153/264)
# babel-plugin-transform-class-properties (155/264)
* assumption-constantSuper/complex-super-class/input.js
x Output mismatch

Expand Down Expand Up @@ -488,9 +488,6 @@ x Output mismatch
* private/optional-chain-optional-member-call-with-transform/input.js
x Output mismatch

* private/optional-chain-optional-property/input.js
x Output mismatch

* private/optional-chain-optional-property-with-transform/input.js
x Output mismatch

Expand Down Expand Up @@ -675,9 +672,6 @@ x Output mismatch
* private-loose/optional-chain-optional-member-call-with-transform/input.js
x Output mismatch

* private-loose/optional-chain-optional-property/input.js
x Output mismatch

* private-loose/optional-chain-optional-property-with-transform/input.js
x Output mismatch

Expand Down