@@ -150,6 +150,45 @@ function parseDeclaration(
150150 }
151151 }
152152 } ) ;
153+ } else if ( subDeclaration . type === 'TsEnumDeclaration' ) {
154+ const comment =
155+ prev !== undefined
156+ ? leadingComment ( src , srcSpanStart , prev . span . end , decl . span . start ) [ 0 ]
157+ : undefined ;
158+ // Construct a synthetic object declaration
159+ const properties : swc . KeyValueProperty [ ] = subDeclaration . members . map ( ( member ) => {
160+ return {
161+ type : 'KeyValueProperty' ,
162+ key : {
163+ type : 'Identifier' ,
164+ value : member . id . value ,
165+ span : member . id . span ,
166+ optional : false ,
167+ } ,
168+ value : member . init ?? {
169+ type : 'StringLiteral' ,
170+ value : member . id . value ,
171+ span : member . id . span ,
172+ } ,
173+ } ;
174+ } ) ;
175+ const syntheticObject : swc . ObjectExpression = {
176+ type : 'ObjectExpression' ,
177+ span : subDeclaration . span ,
178+ properties,
179+ } ;
180+ result . declarations . push ( {
181+ name : subDeclaration . id . value ,
182+ init : syntheticObject ,
183+ comment,
184+ } ) ;
185+ if ( decl . type === 'ExportDeclaration' ) {
186+ result . exports . push ( {
187+ type : 'named' ,
188+ exportedName : subDeclaration . id . value ,
189+ localName : subDeclaration . id . value ,
190+ } ) ;
191+ }
153192 }
154193 return result ;
155194}
@@ -179,7 +218,8 @@ export function parseTopLevelSymbols(
179218 symbols . imports . push ( ...newSyms ) ;
180219 } else if (
181220 item . type === 'VariableDeclaration' ||
182- item . type === 'ExportDeclaration'
221+ item . type === 'ExportDeclaration' ||
222+ item . type === 'TsEnumDeclaration'
183223 ) {
184224 const newSyms = parseDeclaration ( src , srcSpanStart , items [ idx - 1 ] , item ) ;
185225 addTable ( newSyms ) ;
0 commit comments