Closed
Description
EventTarget
objects expose an addEventListener
method, which registers an EventListener
(or EventListenerObject
) with the target. An EventListener
is simply a function from some Event
to void
; however, many EventTarget
objects pass an argument to their EventListener
s with more structure than just Event
.
This is a problem because we completely lose type safety when using addEventListener
. We're forced to let the argument to the EventListener
be any
; coercing it to a more specific type gives an error.
EventTarget
objects should be generic on the type of events being emitted. This would be a breaking change, though.