vite-plugins
vite-plugins copied to clipboard
vite-plugin-require-context - TypeScript
Is your feature request related to a problem? Please describe.
When I use vite-plugin-require-context
plugin in my app, TypeScript throws an error "Property 'context' does not exist on type 'NodeRequire'."
Describe the solution you'd like
Some d.ts
to use and augment the type system so require.context
is not unknown to TS
Describe alternatives you've considered
I'v of course tried to augment NodeRequire interface but without success
Additional context
Pls provide some clear way how to use this plugin in a TypeScript project
Hi @Liwoj It will be appreciated if you can provide some detailed code to reproduce this. :)
IMO this is just a plugin used in vite, and it does not have any compatibility issues of TypeScript/JavaScript.
- Open
- Open new terminal
- run
npm run check
src/App.vue:2:25 - error TS2339: Property 'context' does not exist on type 'NodeRequire'.
2 const imports = require.context('./components');
- Open
- Open new terminal
- run
npm run check
src/App.vue:2:25 - error TS2339: Property 'context' does not exist on type 'NodeRequire'. 2 const imports = require.context('./components');
Any update on that?