Skip to content

Commit e940fdc

Browse files
committed
Don't use innerExpression in parenthesizeForAccess
1 parent 26cf974 commit e940fdc

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/compiler/emitter.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,9 +1646,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
16461646
function parenthesizeForAccess(expr: Expression): LeftHandSideExpression {
16471647
// When diagnosing whether the expression needs parentheses, the decision should be based
16481648
// on the innermost expression in a chain of nested type assertions.
1649-
let innerExpression = expr;
1650-
while (innerExpression.kind === SyntaxKind.TypeAssertionExpression) {
1651-
innerExpression = (<TypeAssertion>innerExpression).expression;
1649+
while (expr.kind === SyntaxKind.TypeAssertionExpression) {
1650+
expr = (<TypeAssertion>expr).expression;
16521651
}
16531652

16541653
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
@@ -1659,9 +1658,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
16591658
// NumberLiteral
16601659
// 1.x -> not the same as (1).x
16611660
//
1662-
if (isLeftHandSideExpression(innerExpression) &&
1663-
innerExpression.kind !== SyntaxKind.NewExpression &&
1664-
innerExpression.kind !== SyntaxKind.NumericLiteral) {
1661+
if (isLeftHandSideExpression(expr) &&
1662+
expr.kind !== SyntaxKind.NewExpression &&
1663+
expr.kind !== SyntaxKind.NumericLiteral) {
16651664

16661665
return <LeftHandSideExpression>expr;
16671666
}

0 commit comments

Comments
 (0)