question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript generics are removed incorrectly

See original GitHub issue

Prettier 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:closed
  • Created 5 years ago
  • Comments:17 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
JamesHenrycommented, Feb 4, 2019

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

2reactions
JamesHenrycommented, Feb 2, 2019

No, it’s the same solution, but obviously want to avoid situations where multiple people are doing the same work

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found