@@ -194,11 +194,35 @@ export function getExportsForSourceFile(typeChecker: ts.TypeChecker, sourceFileS
194
194
}
195
195
}
196
196
197
+ const symbolsMergingResolvedExports : SourceFileExport [ ] = [ ] ;
198
+
197
199
result . forEach ( ( exp : SourceFileExport ) => {
198
200
exp . symbol = getActualSymbol ( exp . symbol , typeChecker ) ;
201
+
202
+ const symbolsDeclarations = getDeclarationsForSymbol ( exp . symbol ) ;
203
+ const importSpecifierDeclaration = symbolsDeclarations . find ( ts . isImportSpecifier ) ;
204
+ if ( symbolsDeclarations . length > 1 && importSpecifierDeclaration !== undefined ) {
205
+ // most likely this export is part of the symbol merging situation
206
+ // where one of the declarations is the imported value but the other is declared locally
207
+ // in this case we need to add an extra export to the exports list to make sure that it is marked as "exported"
208
+ const referencedModule = resolveReferencedModule ( importSpecifierDeclaration . parent . parent . parent , typeChecker ) ;
209
+ if ( referencedModule !== null ) {
210
+ const referencedModuleSymbol = getNodeSymbol ( referencedModule , typeChecker ) ;
211
+ if ( referencedModuleSymbol !== null ) {
212
+ const importedName = ( importSpecifierDeclaration . propertyName ?? importSpecifierDeclaration . name ) . getText ( ) ;
213
+ const exportedItemSymbol = typeChecker . getExportsOfModule ( referencedModuleSymbol ) . find ( ( exportSymbol : ts . Symbol ) => exportSymbol . getName ( ) === importedName ) ;
214
+ if ( exportedItemSymbol !== undefined ) {
215
+ symbolsMergingResolvedExports . push ( {
216
+ ...exp ,
217
+ symbol : getActualSymbol ( exportedItemSymbol , typeChecker ) ,
218
+ } ) ;
219
+ }
220
+ }
221
+ }
222
+ }
199
223
} ) ;
200
224
201
- return result ;
225
+ return [ ... result , ... symbolsMergingResolvedExports ] ;
202
226
}
203
227
204
228
export function resolveIdentifier ( typeChecker : ts . TypeChecker , identifier : ts . Identifier ) : ts . NamedDeclaration | undefined {
0 commit comments