-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prettier 2.1.0 generates broken code with new ...infer T
syntax in TypeScript 4.0
#9041
Comments
By the way I am very surprised that TypeScript can't handle these parentheses... I feel the urge to put these parentheses myself, even if Prettier wouldn't put them... Edit: I guess I just have to live with the fact that |
I am not sure the exact semantics atm. It is actually quite possible that there are cases where I think you'd be able to do |
@bradennapier feel free to open a new issue |
Just replying to the message previous. I'll have to play with the syntax when I can, I'm pretty sure what I said would work but on mobile atm. It seems likely that prettier shouldn't correct either use of it -- or if the () is literally only valid when used as an array then it could be smarter and remove () unless followed by []. If anyone else has time to test to confirm as well that'd be good. The |
@bradennapier You're overthinking it. |
I tried 2 more combos in Input: type Tail<T extends any[]> = T extends [infer U, ...infer R] ? R : never;
type Tail2<T extends any[]> = T extends [infer U, ...(infer R)] ? R : never;
type Tail3<T extends any[]> = T extends [infer U, ...(infer R)[]] ? R : never; Output: type Tail<T extends any[]> = T extends [infer U, ...infer R] ? R : never;
type Tail2<T extends any[]> = T extends [infer U, ...infer R] ? R : never;
type Tail3<T extends any[]> = T extends [infer U, ...(infer R)[]] ? R : never; |
@brodybits The definition of
|
and re-format everything this allowed me to get rid of the prettierignore, see also this issue: prettier/prettier#9041
Prettier 2.1.0
Playground link
Input:
Output:
Expected behavior:
Output should be identical to input. The output given by Prettier does not compile in TypeScript 4.0.
Extra information:
This was mentioned by @bradennapier in #8646 but was forgotten.
I am working around this with
// prettier-ignore
for now.Thank you for this awesome code formatter!
The text was updated successfully, but these errors were encountered: