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

Dom reference forces consuming package to use dom lib

Open asakusuma opened this issue 3 years ago • 1 comments

This line forces consuming packages to use the dom lib when compiling: https://github.com/andywer/threads.js/blob/master/src/types/master.ts#L1

This means that the host package can't properly type check for nodejs only. For example, the compiler will not catch if someone tries to use the global performance object, which doesn't exist in node.

I believe this is related to https://github.com/andywer/threads.js/issues/418

asakusuma avatar Apr 28 '22 17:04 asakusuma

Even so I don't think any fix to this issue would resolve mine, because I am not sure why the @types/node maintainers decided that instead of overriding the Transferable global type, they're just going to define their own Tranferable type like so for the worker_threads module:

type TransferListItem = ArrayBuffer | MessagePort | FileHandle | X509Certificate | Blob;

I'm pretty sure there's a good reason. I opened a discussion many moons ago about it to get some answers, it's yet to be even looked at.

flevi29 avatar Aug 13 '22 07:08 flevi29