TypeScript Version: 3.0.0
Build:Cannot invoke an expression whose type lacks a call signature. Type '((message: any, targetOrigin: string, transfer?: any[]) => void) | ((message: any, transfer?: any...' has no compatible call signatures.
Looks intentional to me. Before you can post a message to a MessageEventSource, you need to know whether it is a Window (which requires a targetOrigin parameter) or a MessagePort or ServiceWorker (which does not accept a targetOrigin parameter).
To expedite the triage process, we need everyone to follow the issue template and instructions.
When you clicked "Create New Issue", the issue form was pre-populated with a template and some instructions. We need you to read those instructions completely, follow them, and then fill in all the fields in that template.
We are not able to assist with issues that don't follow the template instructions as they represent a significantly larger amount of work compared to issues which are correctly specified. Thank you for understanding.
What else do you need? A repro? The message has all the information you need
@marcomura it seems that you need to detect the event.source before using it. The event.source is type of MessageEventSource, while:
type MessageEventSource = WindowProxy | MessagePort | ServiceWorker;
// and
type WindowProxy = Window;
The solution could be:
if (event.source instanceof Window) {
event.source.postMessage('message', 'origin')
}
@lepture event.source instanceof Window will return false for me. You should probably use:
!(e.source instanceof MessagePort) && !(e.source instanceof ServiceWorker)
another resolve:
(<Window>event.source).postMessage('message', 'origin')
Most helpful comment
@marcomura it seems that you need to detect the
event.sourcebefore using it. Theevent.sourceis type ofMessageEventSource, while:The solution could be: