diff --git a/src/services/refactors/moveToNewFile.ts b/src/services/refactors/moveToNewFile.ts index 6a9e8df6bd..e714315f31 100644 --- a/src/services/refactors/moveToNewFile.ts +++ b/src/services/refactors/moveToNewFile.ts @@ -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); diff --git a/tests/cases/fourslash/moveToNewFile_moveNamedImport.ts b/tests/cases/fourslash/moveToNewFile_moveNamedImport.ts new file mode 100644 index 0000000000..63100d05f9 --- /dev/null +++ b/tests/cases/fourslash/moveToNewFile_moveNamedImport.ts @@ -0,0 +1,18 @@ +/// + +// @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(); +` + }, +}); diff --git a/tests/cases/fourslash/moveToNewFile_moveNamespaceImport.ts b/tests/cases/fourslash/moveToNewFile_moveNamespaceImport.ts new file mode 100644 index 0000000000..4d5ee7ffbf --- /dev/null +++ b/tests/cases/fourslash/moveToNewFile_moveNamespaceImport.ts @@ -0,0 +1,18 @@ +/// + +// @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(); +` + }, +});