Don't use innerExpression in parenthesizeForAccess
This commit is contained in:
parent
26cf97430e
commit
e940fdc534
|
@ -1646,9 +1646,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||||
function parenthesizeForAccess(expr: Expression): LeftHandSideExpression {
|
function parenthesizeForAccess(expr: Expression): LeftHandSideExpression {
|
||||||
// When diagnosing whether the expression needs parentheses, the decision should be based
|
// When diagnosing whether the expression needs parentheses, the decision should be based
|
||||||
// on the innermost expression in a chain of nested type assertions.
|
// on the innermost expression in a chain of nested type assertions.
|
||||||
let innerExpression = expr;
|
while (expr.kind === SyntaxKind.TypeAssertionExpression) {
|
||||||
while (innerExpression.kind === SyntaxKind.TypeAssertionExpression) {
|
expr = (<TypeAssertion>expr).expression;
|
||||||
innerExpression = (<TypeAssertion>innerExpression).expression;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
|
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
|
||||||
|
@ -1659,9 +1658,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||||
// NumberLiteral
|
// NumberLiteral
|
||||||
// 1.x -> not the same as (1).x
|
// 1.x -> not the same as (1).x
|
||||||
//
|
//
|
||||||
if (isLeftHandSideExpression(innerExpression) &&
|
if (isLeftHandSideExpression(expr) &&
|
||||||
innerExpression.kind !== SyntaxKind.NewExpression &&
|
expr.kind !== SyntaxKind.NewExpression &&
|
||||||
innerExpression.kind !== SyntaxKind.NumericLiteral) {
|
expr.kind !== SyntaxKind.NumericLiteral) {
|
||||||
|
|
||||||
return <LeftHandSideExpression>expr;
|
return <LeftHandSideExpression>expr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue