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

`setupTwoslashHovers` is unavailable from `shiki-twoslash/dist/dom`, but hover is unavailable without it. #70

Closed threehams closed 3 years ago

threehams commented 3 years ago

Environment

Node 16.0.0 Yarn gatsby-remark-shiki-twoslash: 3.0.7 shiki-twoslash: 1.6.2 Windows 10

Bug

I just did a fairly big version jump of gatsby-remark-shiki-twoslash from 0.7.0 to 3.0.7, and I've started getting errors on the line:

import { setupTwoslashHovers } from "shiki-twoslash/dist/dom";

This import mentioned anywhere in the docs, but it was in the TypeScript website code a while back. Strangely, the code is still in shiki-twoslash source in this project, and dom.d.ts is available in node_modules, but there are no references to setupTwoslashHovers anywhere else, and no dom.js file alongside dom.d.ts to import. If I take out the import, it fixes the errors, I lose all tooltips in code examples.

Has this changed in v2 or v3? There doesn't seem to be a changelog, so I'm not really sure what I'm doing wrong here.

Reproduction

Project link: https://github.com/threehams/typescript-quirks

I am very new to Gatsby and would have trouble cutting this example down.

threehams commented 3 years ago

This bug was introduced in shiki-twoslash@1.4.0. dom.js exists in 1.3.3. https://github.com/shikijs/twoslash/pull/13

threehams commented 3 years ago

From the PR, it was intentionally removed, but my site examples aren't showing any tooltips. This is after removing the yarn.lock file and installing everything from scratch. I'll try to keep tracking down what's going on.

orta commented 3 years ago

You're missing the css update

On Thu, Jul 8, 2021, at 11:47 PM, David Edmondson wrote:

From the PR, it was intentionally removed, but my site examples aren't showing any tooltips. This is after removing the yarn.lock file and installing everything from scratch. I'll try to keep tracking down what's going on.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/shikijs/twoslash/issues/70#issuecomment-876792218, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAL7DRGUZMMMKV2WOWX6ELTWYTJ5ANCNFSM5ABTRBTQ.

threehams commented 3 years ago

OK! Got it. 1.4.0 requires changes to CSS for tooltips to appear: https://github.com/shikijs/twoslash/blob/main/packages/remark-shiki-twoslash/README.md

orta commented 3 years ago

Yeah, I need to do a better job in describing version changes in the lib, that was really a 0.x kinda move, not a 1.x kinda move - #31

threehams commented 3 years ago

Still, I could have struggled with this for two days and still saved time over what I was doing before!

frencojobs commented 3 years ago

@orta That dom.ts is no longer needed right? Should we remove that?

orta commented 3 years ago

Hah, yep, if it's still in there