@@ -3875,18 +3875,14 @@ namespace ts {
38753875 */
38763876 export function parenthesizeForAccess ( expression : Expression ) : LeftHandSideExpression {
38773877 // isLeftHandSideExpression is almost the correct criterion for when it is not necessary
3878- // to parenthesize the expression before a dot. There are two known exceptions :
3878+ // to parenthesize the expression before a dot. The known exception is :
38793879 //
38803880 // NewExpression:
38813881 // new C.x -> not the same as (new C).x
38823882 //
3883- // ObjectLiteral:
3884- // {a:1}.toString() -> is incorrect syntax, should be ({a:1}).toString()
3885- //
38863883 const emittedExpression = skipPartiallyEmittedExpressions ( expression ) ;
38873884 if ( isLeftHandSideExpression ( emittedExpression )
3888- && ( ! isNewExpression ( emittedExpression ) || ( < NewExpression > emittedExpression ) . arguments )
3889- && ! isObjectLiteralExpression ( emittedExpression ) ) {
3885+ && ( emittedExpression . kind !== SyntaxKind . NewExpression || ( < NewExpression > emittedExpression ) . arguments ) ) {
38903886 return < LeftHandSideExpression > expression ;
38913887 }
38923888
@@ -3945,11 +3941,10 @@ namespace ts {
39453941 return recreateOuterExpressions ( expression , mutableCall , OuterExpressionKinds . PartiallyEmittedExpressions ) ;
39463942 }
39473943 }
3948- else {
3949- const leftmostExpressionKind = getLeftmostExpression ( emittedExpression ) . kind ;
3950- if ( leftmostExpressionKind === SyntaxKind . ObjectLiteralExpression || leftmostExpressionKind === SyntaxKind . FunctionExpression ) {
3951- return setTextRange ( createParen ( expression ) , expression ) ;
3952- }
3944+
3945+ const leftmostExpressionKind = getLeftmostExpression ( emittedExpression ) . kind ;
3946+ if ( leftmostExpressionKind === SyntaxKind . ObjectLiteralExpression || leftmostExpressionKind === SyntaxKind . FunctionExpression ) {
3947+ return setTextRange ( createParen ( expression ) , expression ) ;
39533948 }
39543949
39553950 return expression ;
0 commit comments