Merge pull request #14900 from Microsoft/Fix14892

Fix #14892: Add undefined check before using the intializer of for-statment
This commit is contained in:
Mohamed Hegazy
2017-03-29 09:31:00 -07:00
committed by GitHub
10 changed files with 370 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -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) {