mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(transformer/react): missing scope_id for function in fast refresh plugin (#5693)
Fix semantic error in the fast react plugin
This commit is contained in:
parent
a891c31889
commit
f2f5e5aaf5
2 changed files with 8 additions and 18 deletions
|
|
@ -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};
|
||||
|
|
@ -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,
|
||||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
commit: 3bcfee23
|
||||
|
||||
Passed: 38/52
|
||||
Passed: 40/52
|
||||
|
||||
# All Passed:
|
||||
* babel-plugin-transform-nullish-coalescing-operator
|
||||
|
|
@ -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): []
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue