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.06k stars 51 forks source link

Cannot find module 'next' or its corresponding type declarations, though next is installed #174

Closed JoshuaKGoldberg closed 1 year ago

JoshuaKGoldberg commented 1 year ago

I'm a big fan of shiki-twoslash, thanks for making it! But I'm not able to get it to recognize types from the next package. See around https://learning-typescript-git-the-satisfies-operator-joshuakgoldberg.vercel.app/articles/the-satisfies-operator#nextjs-and-satisfies:

Screenshot of Cannot find module 'next' or its corresponding type declarations error in a shiki-twoslash code snippet importing from next

https://github.com/LearningTypeScript/site/pull/100/commits/944659518924f5f30e2b3d70198ac26eb768f599

Shouldn't shiki-twoslash be detecting the Next types from node_modules/next? I also couldn't find explicit docs on type detection anywhere, other than #134 referencing that it exists normally.

orta commented 1 year ago

It should! I'm probably not going to be at a place where I can provide much debugging help, but it's likely that either the next types do something unique (quite possible) or I hadn't accounted for or the folder structure

The interesting code is in

https://github.com/microsoft/TypeScript-Website/blob/v2/packages/ts-twoslasher/src/index.ts#L478-L490

and

https://github.com/microsoft/TypeScript-Website/blob/eaa5e207cc807b259a397962425e7c766b8babe5/packages/typescript-vfs/src/index.ts#L37

JoshuaKGoldberg commented 1 year ago

...huh. It went away on its own. I think this isn't a case of me forgetting to install modules, because it happened in CI. But 🤷

Sorry for the noise either way. Closing this for now, but if someone else sees it too, please speak up!