Here is a snippet of my code
window.addEventListener('message', (e) => {
e.source.postMessage('hi there, I hear you!', '*');
});
Encountered an error:
[ts] The type '((message: any, targetOrigin: string, transfer?: any[]) => void) | ((message: any, transfer?: any[]) => void)' does not have compatible call signatures.
Upon inspecting the postMessage
method, it appears to belong to the window
object with the following signature:
declare function postMessage(
message: any,
targetOrigin: string,
transfer?: any[]
): void;
As I compare this signature to my code, they appear to match. So what could be causing the issue here?