I am using Angular2 + TypeScript and when I try execute this code:
var event = new Event('check');
window.dispatchEvent(event);
This code causing the next error:
failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.
I have tried everything, and found out that this will work:
var event = new CustomEvent('check');
Problem is that CustomEvent is not supported by any IE.
Another thing that works is:
var event = new Event('CustomEvent');
event.initCustomEvent('check');
Problem is that InitCustomEvent is deprecated.
Is there anything I can do to avoid this type error? Maybe make an exception somewhere in typescript? Or use any code that is not deprecated and works for IE Edge?