Skip to content

Commit

Permalink
fix(transformer/react): don't transform declaration of function overl…
Browse files Browse the repository at this point in the history
…oads (#5642)

Found a bug in https://github.com/oxc-project/oxc/actions/runs/10768809028/job/29858692560; We don't need to transform typescript-syntax-only function
  • Loading branch information
Dunqing committed Sep 11, 2024
1 parent 7b543df commit 0739b5f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions crates/oxc_transformer/src/react/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ impl<'a> ReactRefresh<'a> {
}
ExportDefaultDeclarationKind::FunctionDeclaration(func) => {
if let Some(id) = &func.id {
if !is_componentish_name(&id.name) {
if func.is_typescript_syntax() || !is_componentish_name(&id.name) {
return None;
}

Expand All @@ -812,7 +812,7 @@ impl<'a> ReactRefresh<'a> {
return None;
};

if !is_componentish_name(&id.name) {
if func.is_typescript_syntax() || !is_componentish_name(&id.name) {
return None;
}

Expand Down Expand Up @@ -950,7 +950,9 @@ fn get_symbol_id_from_function_and_declarator(stmt: &Statement<'_>) -> Vec<Symbo
let mut symbol_ids = vec![];
match stmt {
Statement::FunctionDeclaration(ref func) => {
symbol_ids.push(func.symbol_id().unwrap());
if !func.is_typescript_syntax() {
symbol_ids.push(func.symbol_id().unwrap());
}
}
Statement::VariableDeclaration(ref decl) => {
symbol_ids.extend(decl.declarations.iter().filter_map(|decl| {
Expand All @@ -959,7 +961,9 @@ fn get_symbol_id_from_function_and_declarator(stmt: &Statement<'_>) -> Vec<Symbo
}
Statement::ExportNamedDeclaration(ref export_decl) => {
if let Some(Declaration::FunctionDeclaration(func)) = &export_decl.declaration {
symbol_ids.push(func.symbol_id().unwrap());
if !func.is_typescript_syntax() {
symbol_ids.push(func.symbol_id().unwrap());
}
} else if let Some(Declaration::VariableDeclaration(decl)) = &export_decl.declaration {
symbol_ids.extend(decl.declarations.iter().filter_map(|decl| {
decl.id.get_binding_identifier().and_then(|id| id.symbol_id.get())
Expand Down

0 comments on commit 0739b5f

Please sign in to comment.