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 c09cc70

Browse filesBrowse files
author
Andy
authored
Fix bug: VariableDeclaration initializer may be undefined (microsoft#24256)
1 parent 153c180 commit c09cc70
Copy full SHA for c09cc70

2 files changed

+4-2Lines changed: 4 additions & 2 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
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace ts.refactor {
7676
case SyntaxKind.ImportEqualsDeclaration:
7777
return !hasModifier(node, ModifierFlags.Export);
7878
case SyntaxKind.VariableStatement:
79-
return (node as VariableStatement).declarationList.declarations.every(d => isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true));
79+
return (node as VariableStatement).declarationList.declarations.every(d => d.initializer && isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true));
8080
default:
8181
return false;
8282
}
Collapse file

‎tests/cases/fourslash/moveToNewFile_moveImport.ts‎

Copy file name to clipboardExpand all lines: tests/cases/fourslash/moveToNewFile_moveImport.ts
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
// @Filename: /a.ts
44
////[|import { a, b } from "m";
5+
////let l;
56
////a;|]
67
////b;
78

@@ -10,8 +11,9 @@ verify.moveToNewFile({
1011
"/a.ts":
1112
`import { b } from "m";
1213
b;`,
13-
"/newFile.ts":
14+
"/l.ts":
1415
`import { a } from "m";
16+
let l;
1517
a;`,
1618
}
1719
});

0 commit comments

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