Simplified parenthesis check for await as yield.

This commit is contained in:
Ron Buckton
2015-05-13 11:15:51 -07:00
parent 3d0991d27d
commit 9a6d308203

View File

@@ -1381,14 +1381,13 @@ var __awaiter = (this && this.__awaiter) || function (generator, ctor) {
}
function needsParenthesisForAwaitExpressionAsYield(node: AwaitExpression) {
for (let current: Node = node; isExpression(current.parent); current = current.parent) {
if (current.parent.kind === SyntaxKind.BinaryExpression) {
if ((<BinaryExpression>current.parent).left === current) {
return true;
}
}
if (node.parent.kind === SyntaxKind.BinaryExpression && !isAssignmentOperator((<BinaryExpression>node.parent).operatorToken.kind)) {
return true;
}
else if (node.parent.kind === SyntaxKind.ConditionalExpression && (<ConditionalExpression>node.parent).condition === node) {
return true;
}
return false;
}