Cherry-pick PR #38377 into release-3.9 (#38386)

Component commits:
4baff1b241 moveToNewFile: handle namespace imports too
Fixes #35591

Co-authored-by: Eli Barzilay <eli@barzilay.org>
This commit is contained in:
TypeScript Bot 2020-05-07 23:56:14 -07:00 committed by GitHub
parent d906a471dd
commit ef028bcd08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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();
`
},
});