Add missing parentheses to arrow function in TSInstantiationExpression (#17724)

This commit is contained in:
fisker Cheung authored and GitHub committed 2025-09-12 01:53:02 +08:00
1 parent c0f194c26b
commit 479a54de66
4 files changed
+31

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
#### Add missing parentheses to arrow function in instantiation expression (#17724 by @fisker)
<!-- prettier-ignore -->
```tsx
// Input
void (<_T extends never>() => {})<never>;
// Prettier stable
void <_T extends never>() => {}<never>;
// Prettier main
void (<_T extends never>() => {})<never>;
```
+3
View File
@@ -881,6 +881,9 @@ function needsParens(path, options) {
case "MatchExpressionCase":
return true;
case "TSInstantiationExpression":
return key === "expression";
case "ConditionalExpression":
return key === "test";
@@ -0,0 +1 @@
void (<_T extends never>() => {})<never>;
@@ -1,5 +1,19 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`17714.ts format 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
void (<_T extends never>() => {})<never>;
=====================================output=====================================
void (<_T extends never>() => {})<never>;
================================================================================
`;
exports[`basic.ts format 1`] = `
====================================options=====================================
parsers: ["typescript"]