moveToNewFile: handle namespace imports too

Fixes #35591
This commit is contained in:
Eli Barzilay 2020-05-06 17:23:03 -04:00
parent 05d59a1f1a
commit 29cf049e61
3 changed files with 37 additions and 0 deletions

View file

@ -533,6 +533,7 @@ namespace ts.refactor {
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.ImportSpecifier:
case SyntaxKind.ImportClause:
case SyntaxKind.NamespaceImport:
return true;
case SyntaxKind.VariableDeclaration:
return isVariableDeclarationInImport(decl as VariableDeclaration);

View file

@ -0,0 +1,18 @@
/// <reference path='fourslash.ts' />
// @Filename: /a.ts
////import { foo as oFoo } from './other';
////[|export const x = oFoo();|]
////export const a = 0;
verify.moveToNewFile({
newFileContents: {
"/a.ts":
`export const a = 0;`,
"/x.ts":
`import { foo as oFoo } from './other';
export const x = oFoo();
`
},
});

View file

@ -0,0 +1,18 @@
/// <reference path='fourslash.ts' />
// @Filename: /a.ts
////import * as o from './other';
////[|export const x = o.foo();|]
////export const a = 0;
verify.moveToNewFile({
newFileContents: {
"/a.ts":
`export const a = 0;`,
"/x.ts":
`import * as o from './other';
export const x = o.foo();
`
},
});