Skip to content

Commit

Permalink
refactor(transformer): simplify TS export assignment transform (#3762)
Browse files Browse the repository at this point in the history
Remove unnecessary jump through a `ModuleDeclaration` visitor, and visit as `TSExportAssignment` directly.
  • Loading branch information
overlookmotel committed Jun 19, 2024
1 parent 512740d commit cd56aa9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
6 changes: 3 additions & 3 deletions crates/oxc_transformer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ impl<'a> Traverse<'a> for Transformer<'a> {
self.x0_typescript.transform_for_statement(stmt);
}

fn enter_module_declaration(
fn enter_ts_export_assignment(
&mut self,
decl: &mut ModuleDeclaration<'a>,
export_assignment: &mut TSExportAssignment<'a>,
_ctx: &mut TraverseCtx<'a>,
) {
self.x0_typescript.transform_module_declaration(decl);
self.x0_typescript.transform_ts_export_assignment(export_assignment);
}
}
6 changes: 0 additions & 6 deletions crates/oxc_transformer/src/typescript/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,6 @@ impl<'a> TypeScript<'a> {
}
}

pub fn transform_module_declaration(&mut self, module_decl: &mut ModuleDeclaration<'a>) {
if let ModuleDeclaration::TSExportAssignment(ts_export_assignment) = &mut *module_decl {
self.transform_ts_export_assignment(ts_export_assignment);
}
}

pub fn transform_jsx_element(&mut self, elem: &mut JSXElement<'a>) {
self.annotations.transform_jsx_element(elem);
}
Expand Down

0 comments on commit cd56aa9

Please sign in to comment.