pinojs / thread-stream

A streaming way to send data to a Node.js Worker Thread
MIT License
229 stars 23 forks source link

TS2304: Cannot find name 'Transferable' #153

Closed kylejeske closed 4 months ago

kylejeske commented 4 months ago

In situations where thread-thread is provided as dependency, the type of "Transferable" is not available and can throw a TS error.

An example:

../other-package/node_modules/.pnpm/thread-stream@3.0.1/node_modules/thread-stream/index.d.ts:89:59 - error TS2304: Cannot find name 'Transferable'.

89   emit(eventName: 'message', message: any, transferList?: Transferable[]): boolean
                                                             ~~~~~~~~~~~~

Found 1 error in ../other-package/node_modules/.pnpm/thread-stream@3.0.1/node_modules/thread-stream/index.d.ts:89

Error: Failed calling tsc.  Exit code: 2

This appears to be that DOM library is not being reference in these circumstances.

It appears that the type Transferable is being used where it should be workerThreads.TransferListItem[]

Added a PR (#152) to address this issue.

mcollina commented 4 months ago

Thanks for reporting!

Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.

mcollina commented 4 months ago

Fixed in #152