Skip to content

Commit 0b5b7ef

Browse files
author
Andy
authored
Fix removal of default import (microsoft#25200)
1 parent f52c881 commit 0b5b7ef

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/services/refactors/convertExport.ts

+1-1
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

+2-2
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,7 @@ edit.applyRefactor({
2929
`import { f } from "./a";
3030
import { f } from "./a";
3131
import { f as g } from "./a";
32-
import, * as a from "./a"; // TODO: GH#24875
32+
import * as a from "./a";
3333
import { f } from "./a";
3434
3535
export { f as default } from "./a";

0 commit comments

Comments
 (0)