I am using Angular2 + TypeScript and when trying to execute this code:
var event = new Event('check'); window.dispatchEvent(event);
This code causes the following error:
failed to execute "dispatchEvent" in "EventTarget": parameter 1 is not of type "Event".
I tried everything and found out that this would work:
var event = new CustomEvent('check');
The problem is that CustomEvent is not supported by any IE.
Other that works:
var event = new Event('CustomEvent'); event.initCustomEvent('check');
The problem is that InitCustomEvent is deprecated.
Is there anything I can do to avoid this type of error? Maybe make an exception somewhere in typescript? Or use any code that is not outdated and works for IE Edge?
javascript angular typescript
roni litman
source share