mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
Merge pull request #15006 from Microsoft/master-14895
[Master] Emit parenthesis around propert/element access expression of casted object literal expression
This commit is contained in:
@@ -3489,8 +3489,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function parenthesizeConciseBody(body: ConciseBody): ConciseBody {
|
||||
const emittedBody = skipPartiallyEmittedExpressions(body);
|
||||
if (emittedBody.kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
if (!isBlock(body) && getLeftmostExpression(body).kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
return setTextRange(createParen(<Expression>body), body);
|
||||
}
|
||||
|
||||
|
||||
@@ -2324,13 +2324,13 @@ namespace ts {
|
||||
// code if the casted expression has a lower precedence than the rest of the
|
||||
// expression.
|
||||
//
|
||||
// To preserve comments, we return a "PartiallyEmittedExpression" here which will
|
||||
// preserve the position information of the original expression.
|
||||
//
|
||||
// Due to the auto-parenthesization rules used by the visitor and factory functions
|
||||
// we can safely elide the parentheses here, as a new synthetic
|
||||
// ParenthesizedExpression will be inserted if we remove parentheses too
|
||||
// aggressively.
|
||||
//
|
||||
// To preserve comments, we return a "PartiallyEmittedExpression" here which will
|
||||
// preserve the position information of the original expression.
|
||||
return createPartiallyEmittedExpression(expression, node);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user