-
-
Notifications
You must be signed in to change notification settings - Fork 502
Closed
Description
Summary
Prettier removes Promise type annotations in TypeScript arrow functions, even with "arrowParens": "always" configured, making it impossible to satisfy TypeScript's requirement for generic type parameters on Promises.
Steps To Reproduce:
- Create a new TypeScript file with an interface containing Promise return types
- Configure Prettier with "arrowParens": "always"
- Save the file and observe Prettier's formatting
- Note that TypeScript shows an error: "Generic type 'Promise' requires 1 type argument(s)"
Expected result
Prettier should preserve the Promise type annotation when formatting TypeScript files, especially when "arrowParens": "always" is set.
Example:
interface Example {
myFunction: (param: string) => Promise<void>;
}Actual result
Prettier removes the type parameter, resulting in invalid TypeScript:
interface Example {
myFunction: (param: string) => Promise;
}This causes TypeScript to error with "Generic type 'Promise' requires 1 type argument(s)".
Additional information
The only current workarounds are // @ts-ignore or // prettier-ignore
Neither solution is ideal for maintaining clean, type-safe code.
VS Code Version: 1.95.3
Prettier Extension Version: 11.0.0
OS and version: Ubuntu 24.04
Prettier Log Output
[INFO] Prettier Options:
{
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"importOrder": [...],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"printWidth": 120,
"arrowParens": "always"
}
[INFO] Prettier Resolution: Prettier Path: /Users/[username]/project/node_modules/prettier
[INFO] Formatting file:///Users/[username]/project/src/types.ts
[INFO] Formatting completed in 0.1s
noahamar, markholland, madaxen86, Ernesto385291, SteffenLanger and 21 more
Metadata
Metadata
Assignees
Labels
No labels