lisonge / vite-plugin-monkey

A vite plugin server and build your.user.js for userscript engine like Tampermonkey, Violentmonkey, Greasemonkey, ScriptCat
MIT License
1.41k stars 73 forks source link

Code completion for $ in vanilla JS files #149

Closed martixy closed 7 months ago

martixy commented 7 months ago

Can this be achieved?

It's nice that vscode understands $ when I import, in say my Svelte component or whatever, but I get none of that in .js files. And actually in a project that mixes some framework I get errors on top the IDE providing completion/hints:

Cannot find module '$' or its corresponding type declarations.

So, is it possible to enable hints/completion for vanilla js files as well? How does it work for the special framework files anyway?

(Tried looking around a bit but I'm not familiar enough with typescript and how it intergrates with the build system to figure out anything.)

lisonge commented 7 months ago

https://github.com/lisonge/vite-plugin-monkey/tree/main/packages/create-monkey/template-empty

lisonge commented 7 months ago

or use vite-plugin-monkey/dist/client instead of $

import {} from 'vite-plugin-monkey/dist/client'
martixy commented 7 months ago

Thank you! That works. A good excuse to look through the plugin's code too I guess.

Tho I'm kinda curious why importing $ still works, it just doesn't auto-complete. Ah well.