mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-23 07:07:09 -05:00
Merge pull request #14900 from Microsoft/Fix14892
Fix #14892: Add undefined check before using the intializer of for-statment
This commit is contained in:
@@ -1478,7 +1478,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const initializer = node.initializer;
|
||||
if (isVariableDeclarationList(initializer)) {
|
||||
if (initializer && isVariableDeclarationList(initializer)) {
|
||||
for (const variable of initializer.declarations) {
|
||||
hoistVariableDeclaration(<Identifier>variable.name);
|
||||
}
|
||||
|
||||
@@ -1287,6 +1287,10 @@ namespace ts {
|
||||
* @param node The node to visit.
|
||||
*/
|
||||
function visitForInitializer(node: ForInitializer): ForInitializer {
|
||||
if (!node) {
|
||||
return node;
|
||||
}
|
||||
|
||||
if (shouldHoistForInitializer(node)) {
|
||||
let expressions: Expression[];
|
||||
for (const variable of node.declarations) {
|
||||
|
||||
Reference in New Issue
Block a user