Skip to content

Commit 29cf049

Browse files
committed
moveToNewFile: handle namespace imports too
Fixes #35591
1 parent 05d59a1 commit 29cf049

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

src/services/refactors/moveToNewFile.ts

+1
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ namespace ts.refactor {
533533
case SyntaxKind.ImportEqualsDeclaration:
534534
case SyntaxKind.ImportSpecifier:
535535
case SyntaxKind.ImportClause:
536+
case SyntaxKind.NamespaceImport:
536537
return true;
537538
case SyntaxKind.VariableDeclaration:
538539
return isVariableDeclarationInImport(decl as VariableDeclaration);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @Filename: /a.ts
4+
////import { foo as oFoo } from './other';
5+
////[|export const x = oFoo();|]
6+
////export const a = 0;
7+
8+
verify.moveToNewFile({
9+
newFileContents: {
10+
"/a.ts":
11+
`export const a = 0;`,
12+
13+
"/x.ts":
14+
`import { foo as oFoo } from './other';
15+
export const x = oFoo();
16+
`
17+
},
18+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @Filename: /a.ts
4+
////import * as o from './other';
5+
////[|export const x = o.foo();|]
6+
////export const a = 0;
7+
8+
verify.moveToNewFile({
9+
newFileContents: {
10+
"/a.ts":
11+
`export const a = 0;`,
12+
13+
"/x.ts":
14+
`import * as o from './other';
15+
export const x = o.foo();
16+
`
17+
},
18+
});

0 commit comments

Comments
 (0)