Closed flevi29 closed 2 years ago
I think MessagePort
might be part of the dom
type library. Try adding "dom"
to your tsconfig.json's compilerOptions.lib
😉
I added dom
to compilerOptions.lib
, and it still doesn't work, I would guess because @types/node
definition of MessagePort
takes priority. Anyhow it wouldn't make sense to add dom
, because this is a Node.js application (something I failed to mention yesterday, sorry), and MessagePort
is defined a little bit differently. (For example instead of onmessage
it has on('message', ( ... ) => { ... })
)
Here is the extended error I omitted yesterday, sorry about that:
error TS2345: Argument of type 'MessagePort' is not assignable to parameter of type 'Transferable'.
Type 'MessagePort' is missing the following properties from type 'MessagePort': onmessage, onmessageerror, addEventListener, removeEventListener, dispatchEvent
I believe both definitions of MessagePort
s should be supported by the types, I mean it is supported without the types (seemingly, pretty sure).
Actually looking at the definitions Transferable
is not defined by this awesome package, so maybe this is a @types/node
issue or something similar, as I cannot find their own definition of Transferable
.
Hello!
I might be doing something wrong, but I am getting
TS2345: Argument of type 'MessagePort' is not assignable to parameter of type 'Transferable'.
when providingTransfer
with aMessagePort
as argument, meanwhile in the description ofTransfer
it is stated thatMessagePort
is a valid argument, and it works if I ignore the error. Test here.