File tree 2 files changed +21
-27
lines changed
crates/oxc_transformer/src/typescript
2 files changed +21
-27
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,26 @@ impl<'a> TypeScriptEnum<'a> {
20
20
Self { ctx, enums : FxHashMap :: default ( ) }
21
21
}
22
22
23
+ pub fn transform_statement ( & mut self , stmt : & mut Statement < ' a > , ctx : & TraverseCtx < ' a > ) {
24
+ let new_stmt = match stmt {
25
+ Statement :: TSEnumDeclaration ( ts_enum_decl) => {
26
+ self . transform_ts_enum ( ts_enum_decl, false , ctx)
27
+ }
28
+ Statement :: ExportNamedDeclaration ( decl) => {
29
+ if let Some ( Declaration :: TSEnumDeclaration ( ts_enum_decl) ) = & decl. declaration {
30
+ self . transform_ts_enum ( ts_enum_decl, true , ctx)
31
+ } else {
32
+ None
33
+ }
34
+ }
35
+ _ => None ,
36
+ } ;
37
+
38
+ if let Some ( new_stmt) = new_stmt {
39
+ * stmt = new_stmt;
40
+ }
41
+ }
42
+
23
43
/// ```TypeScript
24
44
/// enum Foo {
25
45
/// X = 1,
Original file line number Diff line number Diff line change @@ -152,33 +152,7 @@ impl<'a> TypeScript<'a> {
152
152
}
153
153
154
154
pub fn transform_statement ( & mut self , stmt : & mut Statement < ' a > , ctx : & TraverseCtx < ' a > ) {
155
- let new_stmt = match stmt {
156
- match_declaration ! ( Statement ) => {
157
- if let Declaration :: TSEnumDeclaration ( ts_enum_decl) = & stmt. to_declaration ( ) {
158
- self . r#enum . transform_ts_enum ( ts_enum_decl, false , ctx)
159
- } else {
160
- None
161
- }
162
- }
163
- match_module_declaration ! ( Statement ) => {
164
- if let ModuleDeclaration :: ExportNamedDeclaration ( decl) =
165
- stmt. to_module_declaration_mut ( )
166
- {
167
- if let Some ( Declaration :: TSEnumDeclaration ( ts_enum_decl) ) = & decl. declaration {
168
- self . r#enum . transform_ts_enum ( ts_enum_decl, true , ctx)
169
- } else {
170
- None
171
- }
172
- } else {
173
- None
174
- }
175
- }
176
- _ => None ,
177
- } ;
178
-
179
- if let Some ( new_stmt) = new_stmt {
180
- * stmt = new_stmt;
181
- }
155
+ self . r#enum . transform_statement ( stmt, ctx) ;
182
156
}
183
157
184
158
pub fn transform_if_statement ( & mut self , stmt : & mut IfStatement < ' a > ) {
You can’t perform that action at this time.
0 commit comments