Skip to content

EventTarget interface not generic #3599

Closed
@carlpaten

Description

@carlpaten

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 EventListeners 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions