@@ -3875,18 +3875,14 @@ namespace ts {
3875
3875
*/
3876
3876
export function parenthesizeForAccess ( expression : Expression ) : LeftHandSideExpression {
3877
3877
// 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 :
3879
3879
//
3880
3880
// NewExpression:
3881
3881
// new C.x -> not the same as (new C).x
3882
3882
//
3883
- // ObjectLiteral:
3884
- // {a:1}.toString() -> is incorrect syntax, should be ({a:1}).toString()
3885
- //
3886
3883
const emittedExpression = skipPartiallyEmittedExpressions ( expression ) ;
3887
3884
if ( isLeftHandSideExpression ( emittedExpression )
3888
- && ( ! isNewExpression ( emittedExpression ) || ( < NewExpression > emittedExpression ) . arguments )
3889
- && ! isObjectLiteralExpression ( emittedExpression ) ) {
3885
+ && ( emittedExpression . kind !== SyntaxKind . NewExpression || ( < NewExpression > emittedExpression ) . arguments ) ) {
3890
3886
return < LeftHandSideExpression > expression ;
3891
3887
}
3892
3888
@@ -3945,11 +3941,10 @@ namespace ts {
3945
3941
return recreateOuterExpressions ( expression , mutableCall , OuterExpressionKinds . PartiallyEmittedExpressions ) ;
3946
3942
}
3947
3943
}
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 ) ;
3953
3948
}
3954
3949
3955
3950
return expression ;
0 commit comments