-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Option to expand computed TypeScript types on hover #94679
Comments
Update: I found this semi-decent hack that seems to force VSC/TSC to expand the types in some cases:
Wrapping a complex type with this mapped |
also looked into this. |
@Eliav2 I believe adding The case I've asked about is to resolve complex types (maybe that's also part of your issue, but your question was about the 13 extra properties, so this should help you.) |
you are right. but this is still a workaround to this feature request. |
This works pretty well for me: https://stackoverflow.com/a/57683652/2010616 type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never; |
@lydell I believe this works similarly to the solution I'd posted above. It's a great hack; I'm not really sure of edge cases--and this feature should still ideally be added to VSCode itself given how useful it is. |
I have published a npm package for |
It might be nice to gate this behind a modifier key, so we can toggle between expanded and unexpanded while the tooltip is up. |
Any updates on this? VSCode is not showing the computed type, it is just showing me the definition. This makes it really hard to develop when the types are complex. |
This is incredibly painful. There's an extension that does exactly this, but it's half-arsed and stalls the editor. |
https://stackoverflow.com/a/69223288/7872063 Current best hack-y workaround |
Using The hack-y workaround above work, but requires applying the patch with every update. It would be easier with a script to re-apply the patch until a setting is added. PLEASE PROVIDE THIS OR ALTERNATE METHOD OF VIEWING ALL RETURN VALUES. |
How to patch (on a Mac)Known to work on VSCode Version: 1.79.0-insider (Universal). Inspect your MANUAL PROCESS:
AUTO-PATCH WITH SHELL SCRIPT:
( Based on StackOverflow answer by Jeremy Caney / LoveriusB ) |
@n8sabes Thank you for the details. Should this not be made the default in vscode or at least be configurable? |
Hi @doberkofler, The CORRECT FIX is a true VSCode Setting from the team. This hack is the best option I’ve found, but if you or anybody else knows of a better solution please post it. I run VSCode Insiders, which updates frequently, so I wrote and shared the above auto-patch shell script. If the code changes in future builds, the regex in this hack will need to be updated. |
Tried the workarounds below but no luck:
The only one that "worked" is the Would definitely be useful to have this as a VSCode, as a first-class-citizen config. |
@leite08 truncation length is a fix to a different, but similar problem: when there are too many members in an object, and you get Meanwhile, this issue and the solution that worked for you are related to complex types not being resolved by TS/VSCode so we can see what it actually means. This has been in the backlog for quite a while (it is now in the bottom 20% of issues by age), would be great if team took it up, but understandably the backlog is pretty long... |
This one didn’t work for me (nothing shows up in the types panel), but that one seems to be doing fine: https://marketplace.visualstudio.com/items?itemName=mxsdev.typescript-explorer Example screenshot: (I’m not affiliated in any way with the extension developer.) |
Tracked upstream in microsoft/TypeScript#59029 You can test it with TS 5.7+ today by setting: |
When 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:
The impl of actual utils I'm using are inconsequential; it's the same if we'd used
Pick
,Omit
, orPartial
. 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 :)The text was updated successfully, but these errors were encountered: