File tree Expand file tree Collapse file tree 1 file changed +21
-18
lines changed
packages/ts-moose-lib/src Expand file tree Collapse file tree 1 file changed +21
-18
lines changed Original file line number Diff line number Diff line change @@ -21,25 +21,28 @@ const convertSourceFile = (
2121 enums : [ ] as DataEnum [ ] ,
2222 } ;
2323
24- checker
25- . getExportsOfModule ( checker . getSymbolAtLocation ( sourceFile ) ! )
26- . forEach ( ( exported ) => {
27- const declaration = exported . declarations ! [ 0 ] ;
28- if ( isInterfaceDeclaration ( declaration ) ) {
29- const name = declaration . name . text ;
30- const t = checker . getTypeAtLocation ( declaration ) ;
24+ let fileSymbol = checker . getSymbolAtLocation ( sourceFile ) ;
25+ let exports =
26+ fileSymbol === undefined
27+ ? [ ] // empty file
28+ : checker . getExportsOfModule ( fileSymbol ) ;
29+ exports . forEach ( ( exported ) => {
30+ const declaration = exported . declarations ! [ 0 ] ;
31+ if ( isInterfaceDeclaration ( declaration ) ) {
32+ const name = declaration . name . text ;
33+ const t = checker . getTypeAtLocation ( declaration ) ;
3134
32- const columns : Column [ ] = toColumns ( t , checker ) ;
33- output . models . push ( {
34- name,
35- columns,
36- } ) ;
37- }
38- if ( isEnumDeclaration ( declaration ) ) {
39- const t = checker . getTypeAtLocation ( declaration ) ;
40- output . enums . push ( enumConvert ( t ) ) ;
41- }
42- } ) ;
35+ const columns : Column [ ] = toColumns ( t , checker ) ;
36+ output . models . push ( {
37+ name,
38+ columns,
39+ } ) ;
40+ }
41+ if ( isEnumDeclaration ( declaration ) ) {
42+ const t = checker . getTypeAtLocation ( declaration ) ;
43+ output . enums . push ( enumConvert ( t ) ) ;
44+ }
45+ } ) ;
4346 return output ;
4447} ;
4548
You can’t perform that action at this time.
0 commit comments