shikijs / twoslash

You take some Shiki, add a hint of TypeScript compiler, and 🎉 incredible static code samples
https://shikijs.github.io/twoslash/
MIT License
1.08k stars 53 forks source link

JSDoc-style comments in hovertext #64

Open paarthenon opened 3 years ago

paarthenon commented 3 years ago

I'd love to have jsdoc-style comments rendered in the popover. It would help my consumers parse some of my more inscrutable types and give a closer simulation of the experience of using the utilities involved. I'm also interested in using that hypothetical feature to show how documentation is retained from a template to the generated object. Has this come up before? Would you consider it in scope for twoslash?

orta commented 3 years ago

I have thought about it a bit yeah - I'm open to it but I think this should probably be an opt-in behavior. E.g. it's hidden behind a flag like includeJSDocInHover. Though I'm open to having my mind changed once I try it.

For the TS website, I opted against it because most of the time it's a distraction from the thing I'm trying to teach (types) - but most people aren't necessarily using shiki-twoslash the same way.

It would require reusing this info from @typescript/twoslash

orta commented 3 years ago

I added this flag, but it doesn't seem to be doing much in the Jest website https://github.com/facebook/jest/pull/11657

Either the Jest types don't have jsdoc (feasible) or the flag doesn't work (also feasible)

paarthenon commented 3 years ago

Hi Orta!

Thanks for such a fast turnaround on this. I got the chance to try it, and it is indeed working. I'm going to experiment with it some more over the next day or two, but here are a couple of things I noticed:

Thanks again