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
TypeScript generics are removed incorrectly #5817
TypeScript generics are removed incorrectly #5817
Comments
Regression from #5799. cc @JamesHenry |
@JounQin Sorry for the inconvenience, the temporary workaround (#5818) is released in 1.16.3. Prettier 1.16.3 --parser typescript Input: export default {
load<K, T>(k: K, t: T) {
return {k, t};
}
} Output: export default {
load<K, T>(k: K, t: T) {
return { k, t };
}
}; |
Thanks for pushing out a patch @ikatyang, I'm guessing we were just missing coverage for this in the prettier tests? I can work on it and restore the updated version of typescript-estree |
Yeah, we probably just need to fix this missing case. It's still the updated version (the OP can be reproduced) on master as I only reverted it in the 1.16 branch. |
This is because the parser puts the |
That sounds like a parser bug to me; it's not otherwise possible to have any kind of generics on properties 🤔 But if it works... |
@j-f1 Did you not see this? #5817 (comment) I worked on this, just hadn't opened a PR yet. I found the AST oddity yesterday and @armano2 and I agreed that it shouldn't be the case and we need to diverge from babel there (and report it) |
Should I close this PR then? |
No, it's the same solution, but obviously want to avoid situations where multiple people are doing the same work |
Yeah, I didn’t see your comment when I was making the PR. Sorry about that. |
All good 👍 |
looks like there is few more issues here:
|
Oh wow, merging the PR on the other repo caused this issue to be closed. I'm guessing it piggybacked my permissions on both repos? Don't think I've ever seen that before |
Yeah, that’s one of the features of GitHub that comes in handy every so often. |
resolves the issue with generics in object methods in TypeScript and passes the test proposed in the following PR: prettier#5824 resolves prettier#5817
as proposed by @j-f1 in the following PR: prettier#5824 should validate that prettier#5817 does not reappear Co-authored-by: Jed Fox <git@twopointzero.us> Co-authored-by: Christopher J. Brody <chris@brody.consulting>
I think this issue is now resolved by PR #6027 (TS 3.4 update which includes |
I think we need merge test before close this to avoid regressions in future |
as proposed by @j-f1 in the following PR: prettier#5824 should validate that issue prettier#5817 does not reappear closes prettier#5817 as resolved and tested Co-authored-by: Jed Fox <git@twopointzero.us> Co-authored-by: Christopher J. Brody <chris@brody.consulting>
The commit I proposed in PR #5989 should automatically close this issue as resolved and tested. Thanks @evilebottnawi for your attention:) |
as proposed by @j-f1 in the following PR: prettier#5824 should validate that issue prettier#5817 does not reappear this change closes prettier#5817 as resolved and tested this change closes prettier#5824 (PR prettier#5824) as superseded Co-authored-by: Jed Fox <git@twopointzero.us> Co-authored-by: Christopher J. Brody <chris@brody.consulting>
Prettier 1.16.2
Playground link
Input:
Output:
Expected behavior:
preserve TypeScript generics
The text was updated successfully, but these errors were encountered: