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

Add link to types #490

Closed mmamedel closed 2 months ago

mmamedel commented 3 months ago

When you open the library on a Typescript project, I get the following error message on VSCode:

Could not find a declaration file for module 'threads'. '/home/mlage/test/test-threadsjs/node_modules/.pnpm/threads@1.7.0_patch_hash=eohjd6xpj3mgfbvhyvlcjihlim/node_modules/threads/index.mjs' implicitly has an 'any' type.
  There are types at '/home/mlage/test/test-threadsjs/node_modules/threads/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'threads' library may need to update its package.json or typings.ts(7016)

This is just updating the package.json to fix this. Thank you

blordpluto commented 3 months ago

My team uses TypeScript, and while this library looks great so far, this is a blocker for us.

There hasn't been a release in years. Is this project still being maintained? 🤔 We are reluctant to fork something for the sake of merging a single PR.

nickythorne commented 3 months ago

Bump on this also a blocker for us.

Workaround for now:

Either use patch-package as a postinstall script if using npm or yarn. Otherwise use pnpm patch to apply this package.json change (what we decided to do).

mmamedel commented 3 months ago

Honestly what we ended up doing was just writing some helpers to allow using native postMessage and message events with Typescript. Felt more future secure than working with this package. And being the native types, it is all well documented. Let me know if you would be interested, I can put these helper types in a package with a README of how to use them.

andywer commented 2 months ago

Duplicate of merged #470.