From 9a6d308203f7bc8cc73f6ecb00ae1dbd5fc14267 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 13 May 2015 11:15:51 -0700 Subject: [PATCH] Simplified parenthesis check for await as yield. --- src/compiler/emitter.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index e31989e6726..ba4b1010dba 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -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 ((current.parent).left === current) { - return true; - } - } + if (node.parent.kind === SyntaxKind.BinaryExpression && !isAssignmentOperator((node.parent).operatorToken.kind)) { + return true; } - + else if (node.parent.kind === SyntaxKind.ConditionalExpression && (node.parent).condition === node) { + return true; + } + return false; }