Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d579793

Browse filesBrowse files
author
Andy
authored
moveToNewFile: Fix bug for missing importClause (microsoft#24224)
1 parent 75ab60f commit d579793
Copy full SHA for d579793

2 files changed

+3Lines changed: 3 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/services/refactors/moveToNewFile.ts‎

Copy file name to clipboardExpand all lines: src/services/refactors/moveToNewFile.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ namespace ts.refactor {
440440
switch (i.kind) {
441441
case SyntaxKind.ImportDeclaration: {
442442
const clause = i.importClause;
443+
if (!clause) return undefined;
443444
const defaultImport = clause.name && keep(clause.name) ? clause.name : undefined;
444445
const namedBindings = clause.namedBindings && filterNamedBindings(clause.namedBindings, keep);
445446
return defaultImport || namedBindings
Collapse file

‎tests/cases/fourslash/moveToNewFile.ts‎

Copy file name to clipboardExpand all lines: tests/cases/fourslash/moveToNewFile.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/// <reference path='fourslash.ts' />
22

33
// @Filename: /a.ts
4+
////import "./foo";
45
////import { a, b, alreadyUnused } from "./other";
56
////const p = 0;
67
////[|const y = p + b;|]
@@ -11,6 +12,7 @@ verify.moveToNewFile({
1112
"/a.ts":
1213
`import { y } from "./y";
1314
15+
import "./foo";
1416
import { a, alreadyUnused } from "./other";
1517
export const p = 0;
1618
a; y;`,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.