File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -1017,11 +1017,20 @@ export namespace Core {
1017
1017
1018
1018
// Handle export = namespace case where ES6 import cannot resolve the symbol
1019
1019
if ( ! symbol && isIdentifier ( node ) && isImportSpecifier ( node . parent ) ) {
1020
- const importDeclaration = findAncestor ( node , isImportDeclaration ) ;
1021
- if ( importDeclaration && isImportDeclaration ( importDeclaration ) && importDeclaration . moduleSpecifier ) {
1022
- const moduleSymbol = checker . getSymbolAtLocation ( importDeclaration . moduleSpecifier ) ;
1023
- if ( moduleSymbol && moduleSymbol . exports ) {
1024
- symbol = moduleSymbol . exports . get ( node . escapedText ) ;
1020
+ const spec = node . parent ;
1021
+ // Get the imported name: for 'import { foo as bar }', use 'foo'; for 'import { foo }', use 'foo'
1022
+ const importedName = spec . propertyName && isIdentifier ( spec . propertyName )
1023
+ ? spec . propertyName . escapedText
1024
+ : spec . name . escapedText ;
1025
+ const importDecl = findAncestor ( spec , isImportDeclaration ) ;
1026
+ const moduleSymbol = importDecl ?. moduleSpecifier ? checker . getSymbolAtLocation ( importDecl . moduleSpecifier ) : undefined ;
1027
+ if ( moduleSymbol ) {
1028
+ // Use TypeScript's official getExportsOfModule API for robust symbol resolution
1029
+ // This handles complex export= namespace cases and internal resolution rules
1030
+ const moduleExports = checker . getExportsOfModule ( moduleSymbol ) ;
1031
+ const exportedSymbol = find ( moduleExports , s => s . escapedName === importedName ) ;
1032
+ if ( exportedSymbol ) {
1033
+ symbol = exportedSymbol ;
1025
1034
}
1026
1035
}
1027
1036
}
You can’t perform that action at this time.
0 commit comments