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
9 changes: 6 additions & 3 deletions crates/oxc_transformer/src/react/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{cell::Cell, iter::once};
use base64::prelude::{Engine, BASE64_STANDARD};
use oxc_allocator::CloneIn;
use oxc_ast::{ast::*, match_expression, AstBuilder};
use oxc_semantic::{Reference, ReferenceFlags, ScopeId, SymbolFlags, SymbolId};
use oxc_semantic::{Reference, ReferenceFlags, ScopeFlags, ScopeId, SymbolFlags, SymbolId};
use oxc_span::{Atom, GetSpan, SPAN};
use oxc_syntax::operator::AssignmentOperator;
use oxc_traverse::{Ancestor, Traverse, TraverseCtx};
Expand Down Expand Up @@ -666,7 +666,7 @@ impl<'a> ReactRefresh<'a> {
Some(self.ctx.ast.expression_array(SPAN, custom_hooks_in_scope, None)),
)),
);
let fn_expr = self.ctx.ast.expression_function(
let function = self.ctx.ast.function(
FunctionType::FunctionExpression,
SPAN,
None,
Expand All @@ -679,7 +679,10 @@ impl<'a> ReactRefresh<'a> {
Option::<TSTypeAnnotation>::None,
Some(function_body),
);
arguments.push(self.ctx.ast.argument_expression(fn_expr));
let scope_id = ctx.create_child_scope_of_current(ScopeFlags::Function);
function.scope_id.set(Some(scope_id));
arguments
.push(self.ctx.ast.argument_expression(ctx.ast.expression_from_function(function)));
}

let symbol_id =
Expand Down
17 changes: 2 additions & 15 deletions tasks/transform_conformance/oxc.snap.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
commit: 3bcfee23

Passed: 38/52
Passed: 40/52

# All Passed:
* babel-plugin-transform-nullish-coalescing-operator
Expand Down Expand Up @@ -167,7 +167,7 @@ rebuilt : SymbolId(2): []
x Output mismatch


# babel-plugin-transform-react-jsx (24/30)
# babel-plugin-transform-react-jsx (26/30)
* refresh/does-not-get-tripped-by-iifes/input.jsx
Bindings mismatch:
after transform: ScopeId(0): []
Expand All @@ -182,19 +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-valid-signature-for-exotic-ways-to-call-hooks/input.jsx
Missing ScopeId
Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1)]
rebuilt : ScopeId(0): [ScopeId(1), ScopeId(3)]

* refresh/includes-custom-hooks-into-the-signatures/input.jsx
Missing ScopeId
Missing ScopeId
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/supports-typescript-namespace-syntax/input.tsx
x Output mismatch

Expand Down