@@ -239,7 +239,7 @@ namespace ts.codefix {
239239 }
240240
241241 const defaultInfo = getDefaultLikeExportInfo ( importingFile , moduleSymbol , checker , compilerOptions ) ;
242- if ( defaultInfo && defaultInfo . name === symbolName && skipAlias ( defaultInfo . symbol , checker ) === exportedSymbol ) {
242+ if ( defaultInfo && ( defaultInfo . name === symbolName || moduleSymbolToValidIdentifier ( moduleSymbol , compilerOptions . target ) === symbolName ) && skipAlias ( defaultInfo . symbol , checker ) === exportedSymbol ) {
243243 result . push ( { moduleSymbol, importKind : defaultInfo . kind , exportedSymbolIsTypeOnly : isTypeOnlySymbol ( defaultInfo . symbol , checker ) } ) ;
244244 }
245245
@@ -556,8 +556,9 @@ namespace ts.codefix {
556556 const checker = program . getTypeChecker ( ) ;
557557 cancellationToken . throwIfCancellationRequested ( ) ;
558558
559- const defaultInfo = getDefaultLikeExportInfo ( sourceFile , moduleSymbol , checker , program . getCompilerOptions ( ) ) ;
560- if ( defaultInfo && defaultInfo . name === symbolName && symbolHasMeaning ( defaultInfo . symbolForMeaning , currentTokenMeaning ) ) {
559+ const compilerOptions = program . getCompilerOptions ( ) ;
560+ const defaultInfo = getDefaultLikeExportInfo ( sourceFile , moduleSymbol , checker , compilerOptions ) ;
561+ if ( defaultInfo && ( defaultInfo . name === symbolName || moduleSymbolToValidIdentifier ( moduleSymbol , compilerOptions . target ) === symbolName ) && symbolHasMeaning ( defaultInfo . symbolForMeaning , currentTokenMeaning ) ) {
561562 addSymbol ( moduleSymbol , defaultInfo . symbol , defaultInfo . kind , checker ) ;
562563 }
563564
@@ -628,7 +629,7 @@ namespace ts.codefix {
628629 defaultExport . escapedName !== InternalSymbolName . ExportEquals ) {
629630 return { symbolForMeaning : defaultExport , name : defaultExport . getName ( ) } ;
630631 }
631- return { symbolForMeaning : defaultExport , name : moduleSymbolToValidIdentifier ( moduleSymbol , compilerOptions . target ! ) } ;
632+ return { symbolForMeaning : defaultExport , name : moduleSymbolToValidIdentifier ( moduleSymbol , compilerOptions . target ) } ;
632633 }
633634
634635 function getNameForExportDefault ( symbol : Symbol ) : string | undefined {
@@ -937,11 +938,11 @@ namespace ts.codefix {
937938 || ( ! ! globalCachePath && startsWith ( getCanonicalFileName ( globalCachePath ) , toNodeModulesParent ) ) ;
938939 }
939940
940- export function moduleSymbolToValidIdentifier ( moduleSymbol : Symbol , target : ScriptTarget ) : string {
941+ export function moduleSymbolToValidIdentifier ( moduleSymbol : Symbol , target : ScriptTarget | undefined ) : string {
941942 return moduleSpecifierToValidIdentifier ( removeFileExtension ( stripQuotes ( moduleSymbol . name ) ) , target ) ;
942943 }
943944
944- export function moduleSpecifierToValidIdentifier ( moduleSpecifier : string , target : ScriptTarget ) : string {
945+ export function moduleSpecifierToValidIdentifier ( moduleSpecifier : string , target : ScriptTarget | undefined ) : string {
945946 const baseName = getBaseFileName ( removeSuffix ( moduleSpecifier , "/index" ) ) ;
946947 let res = "" ;
947948 let lastCharWasValid = true ;
0 commit comments