This is my code
window.addEventListener('message', (e) => {
e.source.postMessage('hi there, I hear you!', '*');
});
This is the error:
[ts] Cannot invoke an expression whose type lacks a call signature. Type '((message: any, targetOrigin: string, transfer?: any[]) => void) | ((message: any, transfer?: any[]) => void)' has no compatible call signatures.
When I inspect postMessage it seems to be a method on window and have the signature:
declare function postMessage(
message: any,
targetOrigin: string,
transfer?: any[]
): void;
That looks very much like my call signature to me. So what is wrong with my code?