Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

WebWorker postMessage overload wrong for transferrables #1849

Open
tknight0000 opened this issue Nov 19, 2024 · 0 comments
Open

WebWorker postMessage overload wrong for transferrables #1849

tknight0000 opened this issue Nov 19, 2024 · 0 comments

Comments

@tknight0000
Copy link

tknight0000 commented Nov 19, 2024

Main:

let worker: Worker = new Woker(new URL('myWorker', import.meta.url));
...

Worker:

self.onmessage = (event: MessageEvent) => {

   let test: ArrayBuffer = new ArrayBuffer(10);

   (<any>self).postMessage(test, [test]); // Works

   self.postMessage(test, [test]); // Compilation Error (false negative)

   self.postMessage(test, '*', [test]); // Fails to send
});

Erroneous Compilation Error:

error TS2769: No overload matches this call.
Overload 1 of 2, '(message: any, targetOrigin: string, transfer?: Transferable[] | undefined): void', gave the following error.
Argument of type 'ArrayBuffer[]' is not assignable to parameter of type 'string'.
Overload 2 of 2, '(message: any, options?: WindowPostMessageOptions | undefined): void', gave the following error.
Type 'ArrayBuffer[]' has no properties in common with type 'WindowPostMessageOptions'.

self.postMessage(test, [test]);

Typescript Version: 5.6.3

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

No branches or pull requests

1 participant