Merge pull request #15624 from Microsoft/fix15603

Fix var emit order for converted loops
This commit is contained in:
Ron Buckton
2017-05-05 17:48:30 -07:00
committed by GitHub
5 changed files with 77 additions and 1 deletions

View File

@@ -2009,13 +2009,14 @@ namespace ts {
}
else {
assignment = createBinary(<Identifier>decl.name, SyntaxKind.EqualsToken, visitNode(decl.initializer, visitor, isExpression));
setTextRange(assignment, decl);
}
assignments = append(assignments, assignment);
}
}
if (assignments) {
updated = setTextRange(createStatement(reduceLeft(assignments, (acc, v) => createBinary(v, SyntaxKind.CommaToken, acc))), node);
updated = setTextRange(createStatement(inlineExpressions(assignments)), node);
}
else {
// none of declarations has initializer - the entire variable statement can be deleted