andywer / threads.js

🧵 Make web workers & worker threads as simple as a function call.
https://threads.js.org/
MIT License
3.04k stars 161 forks source link

error TS7016: Could not find a declaration file for module 'threads' #462

Open jambudipa opened 1 year ago

jambudipa commented 1 year ago

I am not sure how to configure my node app to support TypeScript when using this package. The compiler complain:

error TS7016: Could not find a declaration file for module 'threads'. 'node_modules/threads/index.mjs' implicitly has an 'any' type. Try npm i --save-dev @types/threads if it exists or add a new declaration (.d.ts) file containing declare module 'threads';,

I have tried both of those things, neither work. I am using npx nodemon src/index.ts to run my app and the threads.d.ts file is in the same folder as its usage.

What can I do?

mgol commented 11 months ago

index.mjs is missing its type definitions. The file is declared in the exports part of package.json: https://github.com/andywer/threads.js/blob/0d1a882f09273cb8482902ae2601fe4ffed6fbab/package.json#L24-L41 so any tool that started evaluating exports instead of main or module: https://github.com/andywer/threads.js/blob/0d1a882f09273cb8482902ae2601fe4ffed6fbab/package.json#L6-L7 will have broken types now.

PR https://github.com/andywer/threads.js/pull/470 is a fix; for now I'm applying it in my project via patch-package.