Fix removal of default import (#25200)

This commit is contained in:
Andy
2018-06-25 12:41:32 -07:00
committed by GitHub
parent f52c881ab1
commit 0b5b7ef547
2 changed files with 3 additions and 3 deletions

View File

@@ -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) });
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);

View File

@@ -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";
@@ -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";