1- use rustc_hash:: FxHashSet ;
2-
31use oxc_allocator:: { TakeIn , Vec as ArenaVec } ;
42use oxc_ast:: ast:: * ;
53use oxc_diagnostics:: OxcDiagnostic ;
@@ -29,7 +27,6 @@ pub struct TypeScriptAnnotations<'a, 'ctx> {
2927 has_jsx_fragment : bool ,
3028 jsx_element_import_name : String ,
3129 jsx_fragment_import_name : String ,
32- type_identifier_names : FxHashSet < Atom < ' a > > ,
3330}
3431
3532impl < ' a , ' ctx > TypeScriptAnnotations < ' a , ' ctx > {
@@ -55,7 +52,6 @@ impl<'a, 'ctx> TypeScriptAnnotations<'a, 'ctx> {
5552 has_jsx_fragment : false ,
5653 jsx_element_import_name,
5754 jsx_fragment_import_name,
58- type_identifier_names : FxHashSet :: default ( ) ,
5955 }
6056 }
6157}
@@ -79,7 +75,7 @@ impl<'a> Traverse<'a> for TypeScriptAnnotations<'a, '_> {
7975 true
8076 } else {
8177 decl. specifiers
82- . retain ( |specifier| self . can_retain_export_specifier ( specifier, ctx) ) ;
78+ . retain ( |specifier| Self :: can_retain_export_specifier ( specifier, ctx) ) ;
8379 // Keep the export declaration if there are still specifiers after removing type exports
8480 !decl. specifiers . is_empty ( )
8581 }
@@ -456,8 +452,6 @@ impl<'a> Traverse<'a> for TypeScriptAnnotations<'a, '_> {
456452 // Remove TS specific statements
457453 stmts. retain ( |stmt| match stmt {
458454 Statement :: ExpressionStatement ( s) => !s. expression . is_typescript_syntax ( ) ,
459- // Any namespaces left after namespace transform are type only, so remove them
460- Statement :: TSModuleDeclaration ( _) => false ,
461455 match_declaration ! ( Statement ) => !stmt. to_declaration ( ) . is_typescript_syntax ( ) ,
462456 // Ignore ModuleDeclaration as it's handled in the program
463457 _ => true ,
@@ -548,17 +542,6 @@ impl<'a> Traverse<'a> for TypeScriptAnnotations<'a, '_> {
548542 fn enter_jsx_fragment ( & mut self , _elem : & mut JSXFragment < ' a > , _ctx : & mut TraverseCtx < ' a > ) {
549543 self . has_jsx_fragment = true ;
550544 }
551-
552- fn enter_ts_module_declaration (
553- & mut self ,
554- decl : & mut TSModuleDeclaration < ' a > ,
555- _ctx : & mut TraverseCtx < ' a > ,
556- ) {
557- // NB: Namespace transform happens in `enter_program` visitor, and replaces retained
558- // namespaces with functions. This visitor is called after, by which time any remaining
559- // namespaces need to be deleted.
560- self . type_identifier_names . insert ( decl. id . name ( ) ) ;
561- }
562545}
563546
564547impl < ' a > TypeScriptAnnotations < ' a , ' _ > {
@@ -615,14 +598,8 @@ impl<'a> TypeScriptAnnotations<'a, '_> {
615598 self . is_jsx_imports ( & id. name )
616599 }
617600
618- fn can_retain_export_specifier (
619- & self ,
620- specifier : & ExportSpecifier < ' a > ,
621- ctx : & TraverseCtx < ' a > ,
622- ) -> bool {
623- if specifier. export_kind . is_type ( )
624- || self . type_identifier_names . contains ( & specifier. exported . name ( ) )
625- {
601+ fn can_retain_export_specifier ( specifier : & ExportSpecifier < ' a > , ctx : & TraverseCtx < ' a > ) -> bool {
602+ if specifier. export_kind . is_type ( ) {
626603 return false ;
627604 }
628605 !matches ! ( & specifier. local, ModuleExportName :: IdentifierReference ( ident) if Self :: is_refers_to_type( ident, ctx) )
0 commit comments