@@ -239,7 +239,7 @@ namespace ts.codefix {
239
239
}
240
240
241
241
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 ) {
243
243
result . push ( { moduleSymbol, importKind : defaultInfo . kind , exportedSymbolIsTypeOnly : isTypeOnlySymbol ( defaultInfo . symbol , checker ) } ) ;
244
244
}
245
245
@@ -556,8 +556,9 @@ namespace ts.codefix {
556
556
const checker = program . getTypeChecker ( ) ;
557
557
cancellationToken . throwIfCancellationRequested ( ) ;
558
558
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 ) ) {
561
562
addSymbol ( moduleSymbol , defaultInfo . symbol , defaultInfo . kind , checker ) ;
562
563
}
563
564
@@ -628,7 +629,7 @@ namespace ts.codefix {
628
629
defaultExport . escapedName !== InternalSymbolName . ExportEquals ) {
629
630
return { symbolForMeaning : defaultExport , name : defaultExport . getName ( ) } ;
630
631
}
631
- return { symbolForMeaning : defaultExport , name : moduleSymbolToValidIdentifier ( moduleSymbol , compilerOptions . target ! ) } ;
632
+ return { symbolForMeaning : defaultExport , name : moduleSymbolToValidIdentifier ( moduleSymbol , compilerOptions . target ) } ;
632
633
}
633
634
634
635
function getNameForExportDefault ( symbol : Symbol ) : string | undefined {
@@ -937,11 +938,11 @@ namespace ts.codefix {
937
938
|| ( ! ! globalCachePath && startsWith ( getCanonicalFileName ( globalCachePath ) , toNodeModulesParent ) ) ;
938
939
}
939
940
940
- export function moduleSymbolToValidIdentifier ( moduleSymbol : Symbol , target : ScriptTarget ) : string {
941
+ export function moduleSymbolToValidIdentifier ( moduleSymbol : Symbol , target : ScriptTarget | undefined ) : string {
941
942
return moduleSpecifierToValidIdentifier ( removeFileExtension ( stripQuotes ( moduleSymbol . name ) ) , target ) ;
942
943
}
943
944
944
- export function moduleSpecifierToValidIdentifier ( moduleSpecifier : string , target : ScriptTarget ) : string {
945
+ export function moduleSpecifierToValidIdentifier ( moduleSpecifier : string , target : ScriptTarget | undefined ) : string {
945
946
const baseName = getBaseFileName ( removeSuffix ( moduleSpecifier , "/index" ) ) ;
946
947
let res = "" ;
947
948
let lastCharWasValid = true ;
0 commit comments