Option to expand computed TypeScript types on hover
See original GitHub issueWhen working with complex types, I often encounter types like this:
It’s opaque enough that without understanding all the utils that are used and computing it in the head, it’s hard to understand what type is being represented. I’d love to have a way to expand it into the fully resolved type, which in the case of the above example would be:
{
a: number;
b?: boolean | null | undefined;
c: string;
d: symbol;
}
The impl of actual utils I’m using are inconsequential; it’s the same if we’d used Pick
, Omit
, or Partial
. It’d be great to be able to expand computed types. I’m not sure whether the responsibility for this lies in VSCode or TypeScript, so if I should be moving this there, let me know 😃
Issue Analytics
- State:
- Created 3 years ago
- Reactions:119
- Comments:11
Top Results From Across the Web
How can I see the full expanded contract of a Typescript type?
expands object types one level deep type Expand<T> = T extends infer O ? { [K in ... which, when we hover over...
Read more >Documentation - TypeScript 4.3
How would we type this JavaScript code in TypeScript? ... When this option is turned on, it becomes an error to override any...
Read more >TypeScript: Improve a way to show type inference information ...
I've seen that IntelliJ do have Alt + = shortcut to see type inference information on Scala ... If I hover, leave it...
Read more >Vue JavaScript Tutorial in Visual Studio Code
To install the vue/cli , in a terminal or command prompt type: ... Now expand the src folder and select the App.vue file....
Read more >Language Server Protocol Specification - 3.17
The following TypeScript definitions describe the base JSON-RPC protocol: ... content type that a client supports in various * result literals like `Hover`, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
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
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
Top GitHub Comments
It might be nice to gate this behind a modifier key, so we can toggle between expanded and unexpanded while the tooltip is up.
Update: I found this semi-decent hack that seems to force VSC/TSC to expand the types in some cases:
type Id<T> = {} & { [P in keyof T]: T[P] };
Wrapping a complex type with this mapped
Id
seems to work. I’ll leave this here for anyone else who has the same problem, but I’d still like a solution without hacks.