TypeScript generics are removed incorrectly
See original GitHub issuePrettier 1.16.2 Playground link
--parser typescript
Input:
export default {
load<K, T>(k: K, t: T) {
return {k, t};
}
}
Output:
export default {
load(k: K, t: T) {
return { k, t };
}
};
Expected behavior: preserve TypeScript generics
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (11 by maintainers)
Top Results From Across the Web
Re-adding a property removed from a generic type with `Omit ...
I suspect the error is caused by the fact that T 's version of prop1 needn't be fully compatible with what Params specifies...
Read more >TypeScript: incorrect type checking with generics ... - YouTrack
TypeScript : incorrect type checking with generics (unsubstituted generics shouldn't be assignable to other types) Original issue: IDE and TypeScript Service ...
Read more >Typescript Generics Explained - Ross Bulat - Medium
The problem here is that we are assigning the number type to both the argument and return type, rendering the function only usable...
Read more >TypeScript: JavaScript With Syntax For Types.
TypeScript extends JavaScript by adding types to the language. TypeScript speeds up your development experience by catching errors and providing fixes ...
Read more >Refactoring with TypeScript Discriminated Union Types and ...
this article is to share an example of code refactoring with type script discriminated union type and Generics.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
No, it’s the same solution, but obviously want to avoid situations where multiple people are doing the same work