Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/services/refactors/convertExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ namespace ts.refactor {
}
else if (namedBindings.kind === SyntaxKind.NamespaceImport) {
// `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";`
changes.deleteNode(importingSourceFile, ref);
changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably, this will also clobber trivia.

const quotePreference = isStringLiteral(clause.parent.moduleSpecifier) ? quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : QuotePreference.Double;
const newImport = makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference);
changes.insertNodeAfter(importingSourceFile, clause.parent, newImport);
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/fourslash/refactorConvertExport_defaultToNamed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
////import f from "./a";
////import { default as f } from "./a";
////import { default as g } from "./a";
////import f, * as a from "./a"; // TODO: GH#24875
////import f, * as a from "./a";
////
////export { default } from "./a";
////export { default as f } from "./a";
Expand All @@ -29,7 +29,7 @@ edit.applyRefactor({
`import { f } from "./a";
import { f } from "./a";
import { f as g } from "./a";
import, * as a from "./a"; // TODO: GH#24875
import * as a from "./a";
import { f } from "./a";

export { f as default } from "./a";
Expand Down