Skip to content

Commit ef028bc

Browse files
TypeScript Botelibarzilay
TypeScript Bot
andauthored
Cherry-pick PR #38377 into release-3.9 (#38386)
Component commits: 4baff1b moveToNewFile: handle namespace imports too Fixes #35591 Co-authored-by: Eli Barzilay <eli@barzilay.org>
1 parent d906a47 commit ef028bc

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

src/services/refactors/moveToNewFile.ts

Lines changed: 1 addition & 0 deletions
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);
Lines changed: 18 additions & 0 deletions
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+
});
Lines changed: 18 additions & 0 deletions
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)