mylesmmurphy / prettify-ts

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

Truncate or skip expansion of `Element` related types. #19

Closed braebo closed 1 month ago

braebo commented 2 months ago

Currently, if an object or interface contains a Element (or extends it, i.e. HTMLElement), then the tooltip get very slow and the content explodes beyond the max length, cutting off everything after it:

Would it be possible to check for instance of Element and just show the type name, i.e. HTMLButtonElement / HTMLInputElement? Happy to take a stab.

Thanks for making this btw!! It's a great idea, and an extremely useful extension 🙏💙

mylesmmurphy commented 2 months ago

Hey @FractalHQ! Sorry it took me so long to get back to you. Thanks for your feedback :)

This is half-implemented currently. If you navigate to the extensions settings, you'll actually see a list of types that can be ignored and behave the way you described. For instance, you can add HTMLElement, React.Component, etc.

The issue I am facing with the current implementation is this feature only works if the types in that list are available in the global scope of the project. In other words, if you add a type to ignore like HTMLElement, and then navigate to a project that does not have that defined, it crashes the prettification. So far I have no found a way around it. 🤔 I am continuing to look into this, and when I do, plan on extending the list of ignored types!

braebo commented 2 months ago

Ah ok, that's too bad there's no simple way to check for or catch those errors before crashing (I haven't looked into it but I trust you have 😅). Let me know if there's anything you'd like me to look into or take a stab at -- looking forward to seeing improvements here either way!

Thanks again for the great extension 🙏

mylesmmurphy commented 1 month ago

This issue has been resolved in the latest release v0.0.18

Users can now navigate to the extension settings and add types to the ignore list 👍 Please let me know if you have any other questions or issues!