You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
danielbjornadal
changed the title
Prettier removes Promise<void> type annotations in TypeScript arrow functions
Prettier removes Promise<void> type and other annotations in TypeScript arrow functions
Nov 22, 2024
Same issue here.
Temporary workaround is to remove the plugins. No matter what plugins I think, cause I had
"@trivago/prettier-plugin-sort-imports",
"prettier-plugin-tailwindcss",
The error occurred no matter which I disabled, as long as one is active.
If you open the repro and navigate to the page.tsx file and save, the extension will change the Promise<number> function return signature to Promise. This doesn't happen when prettier is invoked via the CLI.
If I can do anything else to help debug this, happy to help!
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:
Expected result
Prettier should preserve the Promise type annotation when formatting TypeScript files, especially when "arrowParens": "always" is set.
Example:
Actual result
Prettier removes the type parameter, resulting in invalid TypeScript:
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
The text was updated successfully, but these errors were encountered: