@@ -53,6 +53,7 @@ export default class ImportExportVisitorBuilder {
53
53
if ( astNode . declaration . type === 'Identifier' ) {
54
54
this . namespace . add ( exportMeta , astNode . declaration ) ;
55
55
}
56
+ this . exportMap . exports . set ( 'default' , astNode ) ;
56
57
this . exportMap . namespace . set ( 'default' , exportMeta ) ;
57
58
} ,
58
59
ExportAllDeclaration ( ) {
@@ -86,13 +87,17 @@ export default class ImportExportVisitorBuilder {
86
87
case 'TSInterfaceDeclaration' :
87
88
case 'TSAbstractClassDeclaration' :
88
89
case 'TSModuleDeclaration' :
90
+ this . exportMap . exports . set ( astNode . declaration . id . name , astNode ) ;
89
91
this . exportMap . namespace . set ( astNode . declaration . id . name , captureDoc ( this . source , this . docStyleParsers , astNode ) ) ;
90
92
break ;
91
93
case 'VariableDeclaration' :
92
94
astNode . declaration . declarations . forEach ( ( d ) => {
93
95
recursivePatternCapture (
94
96
d . id ,
95
- ( id ) => this . exportMap . namespace . set ( id . name , captureDoc ( this . source , this . docStyleParsers , d , astNode ) ) ,
97
+ ( id ) => {
98
+ this . exportMap . exports . set ( id . name , astNode ) ;
99
+ this . exportMap . namespace . set ( id . name , captureDoc ( this . source , this . docStyleParsers , d , astNode ) ) ;
100
+ } ,
96
101
) ;
97
102
} ) ;
98
103
break ;
@@ -126,18 +131,21 @@ export default class ImportExportVisitorBuilder {
126
131
) ) ;
127
132
if ( exportedDecls . length === 0 ) {
128
133
// Export is not referencing any local declaration, must be re-exporting
134
+ this . exportMap . exports . set ( 'default' , astNode ) ;
129
135
this . exportMap . namespace . set ( 'default' , captureDoc ( this . source , this . docStyleParsers , astNode ) ) ;
130
136
return ;
131
137
}
132
138
if (
133
139
this . isEsModuleInteropTrue // esModuleInterop is on in tsconfig
134
140
&& ! this . exportMap . namespace . has ( 'default' ) // and default isn't added already
135
141
) {
142
+ this . exportMap . exports . set ( 'default' , { } ) ; // add default export
136
143
this . exportMap . namespace . set ( 'default' , { } ) ; // add default export
137
144
}
138
145
exportedDecls . forEach ( ( decl ) => {
139
146
if ( decl . type === 'TSModuleDeclaration' ) {
140
147
if ( decl . body && decl . body . type === 'TSModuleDeclaration' ) {
148
+ this . exportMap . exports . set ( decl . body . id . name , astNode ) ;
141
149
this . exportMap . namespace . set ( decl . body . id . name , captureDoc ( this . source , this . docStyleParsers , decl . body ) ) ;
142
150
} else if ( decl . body && decl . body . body ) {
143
151
decl . body . body . forEach ( ( moduleBlockNode ) => {
@@ -150,20 +158,19 @@ export default class ImportExportVisitorBuilder {
150
158
if ( ! namespaceDecl ) {
151
159
// TypeScript can check this for us; we needn't
152
160
} else if ( namespaceDecl . type === 'VariableDeclaration' ) {
153
- namespaceDecl . declarations . forEach ( ( d ) => recursivePatternCapture ( d . id , ( id ) => this . exportMap . namespace . set (
154
- id . name ,
155
- captureDoc ( this . source , this . docStyleParsers , decl , namespaceDecl , moduleBlockNode ) ,
156
- ) ) ,
157
- ) ;
161
+ namespaceDecl . declarations . forEach ( ( d ) => recursivePatternCapture ( d . id , ( id ) => {
162
+ this . exportMap . exports . set ( id . name , astNode ) ;
163
+ this . exportMap . namespace . set ( id . name , captureDoc ( this . source , this . docStyleParsers , decl , namespaceDecl , moduleBlockNode ) ) ;
164
+ } ) ) ;
158
165
} else {
159
- this . exportMap . namespace . set (
160
- namespaceDecl . id . name ,
161
- captureDoc ( this . source , this . docStyleParsers , moduleBlockNode ) ) ;
166
+ this . exportMap . exports . set ( namespaceDecl . id . name , astNode ) ;
167
+ this . exportMap . namespace . set ( namespaceDecl . id . name , captureDoc ( this . source , this . docStyleParsers , moduleBlockNode ) ) ;
162
168
}
163
169
} ) ;
164
170
}
165
171
} else {
166
172
// Export as default
173
+ this . exportMap . exports . set ( 'default' , { } ) ;
167
174
this . exportMap . namespace . set ( 'default' , captureDoc ( this . source , this . docStyleParsers , decl ) ) ;
168
175
}
169
176
} ) ;
0 commit comments