Skip to content

Commit cd56aa9

Browse files
committed
refactor(transformer): simplify TS export assignment transform (#3762)
Remove unnecessary jump through a `ModuleDeclaration` visitor, and visit as `TSExportAssignment` directly.
1 parent 512740d commit cd56aa9

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

crates/oxc_transformer/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,11 @@ impl<'a> Traverse<'a> for Transformer<'a> {
284284
self.x0_typescript.transform_for_statement(stmt);
285285
}
286286

287-
fn enter_module_declaration(
287+
fn enter_ts_export_assignment(
288288
&mut self,
289-
decl: &mut ModuleDeclaration<'a>,
289+
export_assignment: &mut TSExportAssignment<'a>,
290290
_ctx: &mut TraverseCtx<'a>,
291291
) {
292-
self.x0_typescript.transform_module_declaration(decl);
292+
self.x0_typescript.transform_ts_export_assignment(export_assignment);
293293
}
294294
}

crates/oxc_transformer/src/typescript/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,6 @@ impl<'a> TypeScript<'a> {
189189
}
190190
}
191191

192-
pub fn transform_module_declaration(&mut self, module_decl: &mut ModuleDeclaration<'a>) {
193-
if let ModuleDeclaration::TSExportAssignment(ts_export_assignment) = &mut *module_decl {
194-
self.transform_ts_export_assignment(ts_export_assignment);
195-
}
196-
}
197-
198192
pub fn transform_jsx_element(&mut self, elem: &mut JSXElement<'a>) {
199193
self.annotations.transform_jsx_element(elem);
200194
}

0 commit comments

Comments
 (0)