@@ -609,7 +609,7 @@ namespace ts.codefix {
609
609
const exported = getDefaultLikeExportWorker ( importingFile , moduleSymbol , checker , compilerOptions ) ;
610
610
if ( ! exported ) return undefined ;
611
611
const { symbol, kind } = exported ;
612
- const info = getDefaultExportInfoWorker ( symbol , moduleSymbol , checker , compilerOptions ) ;
612
+ const info = getDefaultExportInfoWorker ( symbol , checker , compilerOptions ) ;
613
613
return info && { symbol, kind, ...info } ;
614
614
}
615
615
@@ -645,7 +645,7 @@ namespace ts.codefix {
645
645
return allowSyntheticDefaults ? ImportKind . Default : ImportKind . CommonJS ;
646
646
}
647
647
648
- function getDefaultExportInfoWorker ( defaultExport : Symbol , moduleSymbol : Symbol , checker : TypeChecker , compilerOptions : CompilerOptions ) : { readonly symbolForMeaning : Symbol , readonly name : string } | undefined {
648
+ function getDefaultExportInfoWorker ( defaultExport : Symbol , checker : TypeChecker , compilerOptions : CompilerOptions ) : { readonly symbolForMeaning : Symbol , readonly name : string } | undefined {
649
649
const localSymbol = getLocalSymbolForExportDefault ( defaultExport ) ;
650
650
if ( localSymbol ) return { symbolForMeaning : localSymbol , name : localSymbol . name } ;
651
651
@@ -659,23 +659,21 @@ namespace ts.codefix {
659
659
// but we can still offer completions for it.
660
660
// - `aliased.parent` will be undefined if the module is exporting `globalThis.something`,
661
661
// or another expression that resolves to a global.
662
- return getDefaultExportInfoWorker ( aliased , aliased . parent , checker , compilerOptions ) ;
662
+ return getDefaultExportInfoWorker ( aliased , checker , compilerOptions ) ;
663
663
}
664
664
}
665
665
666
666
if ( defaultExport . escapedName !== InternalSymbolName . Default &&
667
667
defaultExport . escapedName !== InternalSymbolName . ExportEquals ) {
668
668
return { symbolForMeaning : defaultExport , name : defaultExport . getName ( ) } ;
669
669
}
670
- return { symbolForMeaning : defaultExport , name : moduleSymbolToValidIdentifier ( moduleSymbol , compilerOptions . target ) } ;
670
+ return { symbolForMeaning : defaultExport , name : getNameForExportedSymbol ( defaultExport , compilerOptions . target ) } ;
671
671
}
672
672
673
673
function getNameForExportDefault ( symbol : Symbol ) : string | undefined {
674
674
return symbol . declarations && firstDefined ( symbol . declarations , declaration => {
675
675
if ( isExportAssignment ( declaration ) ) {
676
- if ( isIdentifier ( declaration . expression ) ) {
677
- return declaration . expression . text ;
678
- }
676
+ return tryCast ( skipOuterExpressions ( declaration . expression ) , isIdentifier ) ?. text ;
679
677
}
680
678
else if ( isExportSpecifier ( declaration ) ) {
681
679
Debug . assert ( declaration . name . text === InternalSymbolName . Default , "Expected the specifier to be a default export" ) ;
0 commit comments