diff --git a/crates/oxc_transformer/src/react/refresh.rs b/crates/oxc_transformer/src/react/refresh.rs index a576a4e110ceb..546dbf42fefea 100644 --- a/crates/oxc_transformer/src/react/refresh.rs +++ b/crates/oxc_transformer/src/react/refresh.rs @@ -470,12 +470,13 @@ impl<'a> ReactRefresh<'a> { fn create_registration( &mut self, persistent_id: Atom<'a>, + reference_flags: ReferenceFlags, ctx: &mut TraverseCtx<'a>, ) -> AssignmentTarget<'a> { let symbol_id = ctx.generate_uid_in_root_scope("c", SymbolFlags::FunctionScopedVariable); self.registrations.push((symbol_id, persistent_id)); let name = ctx.ast.atom(ctx.symbols().get_name(symbol_id)); - let ident = ctx.create_reference_id(SPAN, name, Some(symbol_id), ReferenceFlags::Write); + let ident = ctx.create_reference_id(SPAN, name, Some(symbol_id), reference_flags); let ident = ctx.ast.simple_assignment_target_from_identifier_reference(ident); ctx.ast.assignment_target_simple(ident) } @@ -557,7 +558,11 @@ impl<'a> ReactRefresh<'a> { *expr = ctx.ast.expression_assignment( SPAN, AssignmentOperator::Assign, - self.create_registration(ctx.ast.atom(inferred_name), ctx), + self.create_registration( + ctx.ast.atom(inferred_name), + ReferenceFlags::read_write(), + ctx, + ), ctx.ast.move_expression(expr), ); } @@ -584,7 +589,7 @@ impl<'a> ReactRefresh<'a> { id: &BindingIdentifier<'a>, ctx: &mut TraverseCtx<'a>, ) -> Statement<'a> { - let left = self.create_registration(id.name.clone(), ctx); + let left = self.create_registration(id.name.clone(), ReferenceFlags::Write, ctx); let right = ctx.create_bound_reference_id( SPAN, id.name.clone(), diff --git a/tasks/transform_conformance/oxc.snap.md b/tasks/transform_conformance/oxc.snap.md index 945ca0ebec1c6..fb4db3cd2accb 100644 --- a/tasks/transform_conformance/oxc.snap.md +++ b/tasks/transform_conformance/oxc.snap.md @@ -1,6 +1,6 @@ commit: 3bcfee23 -Passed: 32/52 +Passed: 38/52 # All Passed: * babel-plugin-transform-nullish-coalescing-operator @@ -167,12 +167,7 @@ rebuilt : SymbolId(2): [] x Output mismatch -# babel-plugin-transform-react-jsx (18/30) -* refresh/can-handle-implicit-arrow-returns/input.jsx -Reference flags mismatch: -after transform: ReferenceId(18): ReferenceFlags(Write) -rebuilt : ReferenceId(31): ReferenceFlags(Read | Write) - +# babel-plugin-transform-react-jsx (24/30) * refresh/does-not-get-tripped-by-iifes/input.jsx Bindings mismatch: after transform: ScopeId(0): [] @@ -187,20 +182,6 @@ rebuilt : SymbolId(0): ScopeId(0) * refresh/does-not-transform-it-because-it-is-not-used-in-the-AST/input.jsx x Output mismatch -* refresh/generates-signatures-for-function-expressions-calling-hooks/input.jsx -Reference flags mismatch: -after transform: ReferenceId(18): ReferenceFlags(Write) -rebuilt : ReferenceId(4): ReferenceFlags(Read | Write) -Reference flags mismatch: -after transform: ReferenceId(17): ReferenceFlags(Write) -rebuilt : ReferenceId(7): ReferenceFlags(Read | Write) -Reference flags mismatch: -after transform: ReferenceId(22): ReferenceFlags(Write) -rebuilt : ReferenceId(19): ReferenceFlags(Read | Write) -Reference flags mismatch: -after transform: ReferenceId(21): ReferenceFlags(Write) -rebuilt : ReferenceId(22): ReferenceFlags(Read | Write) - * refresh/generates-valid-signature-for-exotic-ways-to-call-hooks/input.jsx Missing ScopeId Scope children mismatch: @@ -214,53 +195,6 @@ Scope children mismatch: after transform: ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(4)] rebuilt : ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(3), ScopeId(5), ScopeId(6)] -* refresh/registers-capitalized-identifiers-in-hoc-calls/input.jsx -Reference flags mismatch: -after transform: ReferenceId(8): ReferenceFlags(Write) -rebuilt : ReferenceId(3): ReferenceFlags(Read | Write) - -* refresh/registers-likely-hocs-with-inline-functions-1/input.jsx -Reference flags mismatch: -after transform: ReferenceId(5): ReferenceFlags(Write) -rebuilt : ReferenceId(1): ReferenceFlags(Read | Write) -Reference flags mismatch: -after transform: ReferenceId(9): ReferenceFlags(Write) -rebuilt : ReferenceId(6): ReferenceFlags(Read | Write) -Reference flags mismatch: -after transform: ReferenceId(8): ReferenceFlags(Write) -rebuilt : ReferenceId(8): ReferenceFlags(Read | Write) -Reference flags mismatch: -after transform: ReferenceId(14): ReferenceFlags(Write) -rebuilt : ReferenceId(12): ReferenceFlags(Read | Write) -Reference flags mismatch: -after transform: ReferenceId(13): ReferenceFlags(Write) -rebuilt : ReferenceId(14): ReferenceFlags(Read | Write) -Reference flags mismatch: -after transform: ReferenceId(12): ReferenceFlags(Write) -rebuilt : ReferenceId(16): ReferenceFlags(Read | Write) - -* refresh/registers-likely-hocs-with-inline-functions-2/input.jsx -Reference flags mismatch: -after transform: ReferenceId(4): ReferenceFlags(Write) -rebuilt : ReferenceId(0): ReferenceFlags(Read | Write) -Reference flags mismatch: -after transform: ReferenceId(3): ReferenceFlags(Write) -rebuilt : ReferenceId(2): ReferenceFlags(Read | Write) -Reference flags mismatch: -after transform: ReferenceId(2): ReferenceFlags(Write) -rebuilt : ReferenceId(4): ReferenceFlags(Read | Write) - -* refresh/registers-likely-hocs-with-inline-functions-3/input.jsx -Reference flags mismatch: -after transform: ReferenceId(4): ReferenceFlags(Write) -rebuilt : ReferenceId(0): ReferenceFlags(Read | Write) -Reference flags mismatch: -after transform: ReferenceId(3): ReferenceFlags(Write) -rebuilt : ReferenceId(2): ReferenceFlags(Read | Write) -Reference flags mismatch: -after transform: ReferenceId(2): ReferenceFlags(Write) -rebuilt : ReferenceId(4): ReferenceFlags(Read | Write) - * refresh/supports-typescript-namespace-syntax/input.tsx x Output mismatch