@@ -420,17 +420,22 @@ namespace ts.codefix {
420
420
function getDefaultLikeExportInfo (
421
421
moduleSymbol : Symbol , checker : TypeChecker , compilerOptions : CompilerOptions ,
422
422
) : { readonly symbol : Symbol , readonly symbolForMeaning : Symbol , readonly name : string , readonly kind : ImportKind . Default | ImportKind . Equals } | undefined {
423
- const exported = getDefaultLikeExportWorker ( moduleSymbol , checker ) ;
423
+ const exported = getDefaultLikeExportWorker ( moduleSymbol , checker , compilerOptions ) ;
424
424
if ( ! exported ) return undefined ;
425
425
const { symbol, kind } = exported ;
426
426
const info = getDefaultExportInfoWorker ( symbol , moduleSymbol , checker , compilerOptions ) ;
427
427
return info && { symbol, kind, ...info } ;
428
428
}
429
429
430
- function getDefaultLikeExportWorker ( moduleSymbol : Symbol , checker : TypeChecker ) : { readonly symbol : Symbol , readonly kind : ImportKind . Default | ImportKind . Equals } | undefined {
430
+ function getDefaultLikeExportWorker ( moduleSymbol : Symbol , checker : TypeChecker , compilerOptions : CompilerOptions ) : { readonly symbol : Symbol , readonly kind : ImportKind . Default | ImportKind . Equals } | undefined {
431
431
const defaultExport = checker . tryGetMemberInModuleExports ( InternalSymbolName . Default , moduleSymbol ) ;
432
432
if ( defaultExport ) return { symbol : defaultExport , kind : ImportKind . Default } ;
433
433
const exportEquals = checker . resolveExternalModuleSymbol ( moduleSymbol ) ;
434
+
435
+ // When ESModule interop is on we want to always use default style instead
436
+ if ( getEsModuleInterop ( compilerOptions ) ) {
437
+ return { symbol : exportEquals , kind : ImportKind . Default } ;
438
+ }
434
439
return exportEquals === moduleSymbol ? undefined : { symbol : exportEquals , kind : ImportKind . Equals } ;
435
440
}
436
441
@@ -550,6 +555,7 @@ namespace ts.codefix {
550
555
defaultImport === undefined ? undefined : createIdentifier ( defaultImport ) ,
551
556
namedImports . map ( n => createImportSpecifier ( /*propertyName*/ undefined , createIdentifier ( n ) ) ) , moduleSpecifier , quotePreference ) ) ;
552
557
}
558
+
553
559
if ( namespaceLikeImport ) {
554
560
insertImport ( changes , sourceFile , namespaceLikeImport . importKind === ImportKind . Equals
555
561
? createImportEqualsDeclaration ( /*decorators*/ undefined , /*modifiers*/ undefined , createIdentifier ( namespaceLikeImport . name ) , createExternalModuleReference ( quotedModuleSpecifier ) )
0 commit comments