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.

Option to expand computed TypeScript types on hover

See original GitHub issue

When working with complex types, I often encounter types like this:

image

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:open
  • Created 3 years ago
  • Reactions:119
  • Comments:11

github_iconTop GitHub Comments

17reactions
glenjamincommented, Nov 18, 2021

It might be nice to gate this behind a modifier key, so we can toggle between expanded and unexpanded while the tooltip is up.

15reactions
MKRherecommented, Apr 9, 2020

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.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

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 Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found