Skip to content

Commit 7879f85

Browse files
authored
fix(formatter): Add parentheses inside UpdateExpression (#13825)
1 parent 7371bad commit 7879f85

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

crates/oxc_formatter/src/parentheses/expression.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ impl<'a> NeedsParentheses<'a> for AstNode<'a, TSTypeAssertion<'a>> {
662662
| AstNodes::IdentifierReference(_)
663663
| AstNodes::AssignmentExpression(_)
664664
| AstNodes::AssignmentTargetWithDefault(_)
665+
| AstNodes::UpdateExpression(_)
665666
)
666667
}
667668
}
@@ -937,6 +938,7 @@ fn ts_as_or_satisfies_needs_parens(parent: &AstNodes<'_>) -> bool {
937938
| AstNodes::PrivateFieldExpression(_)
938939
| AstNodes::AssignmentExpression(_)
939940
| AstNodes::AssignmentTargetWithDefault(_)
941+
| AstNodes::UpdateExpression(_)
940942
)
941943
}
942944

tasks/coverage/snapshots/formatter_typescript.snap

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ commit: 261630d6
22

33
formatter_typescript Summary:
44
AST Parsed : 8816/8816 (100.00%)
5-
Positive Passed: 8757/8816 (99.33%)
5+
Positive Passed: 8758/8816 (99.34%)
66
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/APISample_jsdoc.ts
77

88
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/amdLikeInputDeclarationEmit.ts
@@ -45,8 +45,6 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/readonlyAssignme
4545

4646
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/reducibleIndexedAccessTypes.ts
4747

48-
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/referenceSatisfiesExpression.ts
49-
5048
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/reverseMappedTypeInferenceSameSource1.ts
5149

5250
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/sourceMapValidationClasses.ts

tasks/prettier_conformance/snapshots/prettier.ts.snap.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ts compatibility: 350/573 (61.08%)
1+
ts compatibility: 351/573 (61.26%)
22

33
# Failed
44

@@ -18,7 +18,7 @@ ts compatibility: 350/573 (61.08%)
1818
| typescript/array/comment.ts | 💥 | 87.50% |
1919
| typescript/arrow/16067.ts | 💥💥 | 95.92% |
2020
| typescript/arrow/comments.ts | 💥✨ | 44.44% |
21-
| typescript/as/as.ts | 💥 | 67.72% |
21+
| typescript/as/as.ts | 💥 | 69.29% |
2222
| typescript/as/assignment.ts | 💥 | 86.67% |
2323
| typescript/as/assignment2.ts | 💥 | 94.12% |
2424
| typescript/as/export_default_as.ts | 💥 | 0.00% |
@@ -225,5 +225,4 @@ ts compatibility: 350/573 (61.08%)
225225
| typescript/union/consistent-with-flow/single-type.ts | 💥 | 3.39% |
226226
| typescript/union/consistent-with-flow/within-tuple.ts | 💥 | 16.51% |
227227
| typescript/union/single-type/single-type.ts | 💥 | 33.33% |
228-
| typescript/update-expression/update-expressions.ts | 💥 | 81.25% |
229228
| typescript/webhost/webtsc.ts | 💥 | 99.08% |

0 commit comments

Comments
 (0)