@@ -28,24 +28,25 @@ function getModuleInfo(moduleId, parser) {
2828 namedExports : { }
2929 } ;
3030 if ( ! fileNodes [ moduleId ] ) {
31- const classDeclarations = { } ;
3231 const absolutePath = path . join ( process . cwd ( ) , moduleRoot , moduleId + '.js' ) ;
3332 const file = fs . readFileSync ( absolutePath , 'UTF-8' ) ;
34- const node = fileNodes [ moduleId ] = parser . astBuilder . build ( file , absolutePath ) ;
35- if ( node . program && node . program . body ) {
36- const nodes = node . program . body ;
37- for ( let i = 0 , ii = nodes . length ; i < ii ; ++ i ) {
38- const node = nodes [ i ] ;
39- if ( node . type === 'ClassDeclaration' ) {
40- classDeclarations [ node . id . name ] = node ;
41- } else if ( node . type === 'ExportDefaultDeclaration' ) {
42- const classDeclaration = classDeclarations [ node . declaration . name ] ;
43- if ( classDeclaration ) {
44- moduleInfo . defaultExport = classDeclaration . id . name ;
45- }
46- } else if ( node . type === 'ExportNamedDeclaration' && node . declaration && node . declaration . type === 'ClassDeclaration' ) {
47- moduleInfo . namedExports [ node . declaration . id . name ] = true ;
33+ fileNodes [ moduleId ] = parser . astBuilder . build ( file , absolutePath ) ;
34+ }
35+ const node = fileNodes [ moduleId ] ;
36+ if ( node . program && node . program . body ) {
37+ const classDeclarations = { } ;
38+ const nodes = node . program . body ;
39+ for ( let i = 0 , ii = nodes . length ; i < ii ; ++ i ) {
40+ const node = nodes [ i ] ;
41+ if ( node . type === 'ClassDeclaration' ) {
42+ classDeclarations [ node . id . name ] = node ;
43+ } else if ( node . type === 'ExportDefaultDeclaration' ) {
44+ const classDeclaration = classDeclarations [ node . declaration . name ] ;
45+ if ( classDeclaration ) {
46+ moduleInfo . defaultExport = classDeclaration . id . name ;
4847 }
48+ } else if ( node . type === 'ExportNamedDeclaration' && node . declaration && node . declaration . type === 'ClassDeclaration' ) {
49+ moduleInfo . namedExports [ node . declaration . id . name ] = true ;
4950 }
5051 }
5152 }
@@ -154,7 +155,6 @@ exports.astNodeVisitor = {
154155 node . comments . forEach ( comment => {
155156 // Replace typeof Foo with Class<Foo>
156157 comment . value = comment . value . replace ( / t y p e o f ( [ ^ , \| \} \> ] * ) ( [ , \| \} \> ] ) / g, 'Class<$1>$2' ) ;
157- debugger
158158
159159 // Convert `import("path/to/module").export` to
160160 // `module:path/to/module~Name`
0 commit comments