moveToNewFile: Fix bug for missing importClause (#24224)

This commit is contained in:
Andy
2018-05-17 14:32:12 -07:00
committed by GitHub
parent 75ab60f199
commit d579793d0a
2 changed files with 3 additions and 0 deletions

View File

@@ -440,6 +440,7 @@ namespace ts.refactor {
switch (i.kind) {
case SyntaxKind.ImportDeclaration: {
const clause = i.importClause;
if (!clause) return undefined;
const defaultImport = clause.name && keep(clause.name) ? clause.name : undefined;
const namedBindings = clause.namedBindings && filterNamedBindings(clause.namedBindings, keep);
return defaultImport || namedBindings

View File

@@ -1,6 +1,7 @@
/// <reference path='fourslash.ts' />
// @Filename: /a.ts
////import "./foo";
////import { a, b, alreadyUnused } from "./other";
////const p = 0;
////[|const y = p + b;|]
@@ -11,6 +12,7 @@ verify.moveToNewFile({
"/a.ts":
`import { y } from "./y";
import "./foo";
import { a, alreadyUnused } from "./other";
export const p = 0;
a; y;`,