mylesmmurphy / prettify-ts

Prettify TypeScript: Better Type Previews
https://marketplace.visualstudio.com/items?itemName=MylesMurphy.prettify-ts
MIT License
264 stars 8 forks source link

[Request] Disable expansion of generic objects #39

Open dakaza98 opened 1 month ago

dakaza98 commented 1 month ago

Hi! First I just want to say great job with this plugin, it is really handy! Keep up the good work!

My issue

I work a lot with Angular and therefore a lot with Observables from rxjs. When I hover on my observable type, the list gets very long since observable is a quite large object so I have to scroll quite far down.

image

This is the definition of UnmappedPdfs image

I tried using the Skipped type names setting by adding Observable to the list but this did not have any effect and when I hovered again, the whole observable type still got expended. image

I did notice however that when i changed the setting to the exact type it worked image

image

However, this also disables the expanding of my own type UnmappedPdfs.

What I would like to achieve

It would be nice if I could in some way not have the observable be expended when I hover it. So instead of seeing all the observables properties I would instead see

Observable<{ pdfs: string[], verified: boolean }>

How to solve this

I'm not sure how to solve this and you know the plugin better than me. Would perhaps allowing generic types in the skip type name be an option? I also saw issue #32, perhaps that could be a solution to the issue?

Let me know what you think and if you think that this would be a valuable feature or if it is beyond the scope of this plugin! Cheers!

mylesmmurphy commented 1 month ago

Hey @dakaza98! Thanks for mentioning this.

Generics are absolutely a sore spot for this extension right now, the hardest part has been knowing when to show the "apparent" type (resolved generic), or when to do what you showed above.

Right now there is custom logic for Promises to unwrap the type argument but not the Promise type itself. I could turn that into another setting where items can be added. So if you added "Observable" to that list, it could display as you mentioned!

As a side note, I use Angular at work and have ran into how awful observables look with my extension as well, so definitely want to get this cleaned up! 😄

Edit: If you have a good idea for the setting name, and what the default values should be (including "Promise"), I'd love some input. "Unwrap Arguments Type Names"?

dakaza98 commented 1 month ago

Wonderful! Skip Generic Type Names, perhaps? Unwrap Arguments Type Names could also work.