threads.js icon indicating copy to clipboard operation
threads.js copied to clipboard

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

Open jambudipa opened this issue 2 years ago • 1 comments

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?

jambudipa avatar Feb 08 '23 16:02 jambudipa

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.

mgol avatar Sep 27 '23 10:09 mgol