Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
jambudipa opened this issue Feb 8, 2023 · 1 comment
Open

Comments

@jambudipa
Copy link

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
Copy link

mgol commented Sep 27, 2023

index.mjs is missing its type definitions. The file is declared in the exports part of package.json:

threads.js/package.json

Lines 24 to 41 in 0d1a882

"exports": {
".": {
"require": "./dist/index.js",
"default": "./index.mjs"
},
"./observable": {
"require": "./observable.js",
"default": "./observable.mjs"
},
"./register": {
"require": "./register.js",
"default": "./register.mjs"
},
"./worker": {
"require": "./worker.js",
"default": "./worker.mjs"
}
},

so any tool that started evaluating exports instead of main or module:
"main": "dist/index.js",
"module": "dist-esm/index.js",

will have broken types now.

PR #470 is a fix; for now I'm applying it in my project via patch-package.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants