Skip to content

Commit 13b43b9

Browse files
author
Andy Hanson
committed
Fix removal of default import
1 parent 878bf80 commit 13b43b9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/services/refactors/convertExport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ namespace ts.refactor {
148148
}
149149
else if (namedBindings.kind === SyntaxKind.NamespaceImport) {
150150
// `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";`
151-
changes.deleteNode(importingSourceFile, ref);
151+
changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) });
152152
const quotePreference = isStringLiteral(clause.parent.moduleSpecifier) ? quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : QuotePreference.Double;
153153
const newImport = makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference);
154154
changes.insertNodeAfter(importingSourceFile, clause.parent, newImport);

tests/cases/fourslash/refactorConvertExport_defaultToNamed.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
////import f from "./a";
88
////import { default as f } from "./a";
99
////import { default as g } from "./a";
10-
////import f, * as a from "./a"; // TODO: GH#24875
10+
////import f, * as a from "./a";
1111
////
1212
////export { default } from "./a";
1313
////export { default as f } from "./a";
@@ -29,7 +29,8 @@ edit.applyRefactor({
2929
`import { f } from "./a";
3030
import { f } from "./a";
3131
import { f as g } from "./a";
32-
import f, * as a from "./a"; // TODO: GH#24875
32+
import * as a from "./a";
33+
import { f } from "./a";
3334
3435
export { f as default } from "./a";
3536
export { f } from "./a";

0 commit comments

Comments
 (0)