Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventTarget interface not generic #3599

Closed
carlpaten opened this issue Jun 22, 2015 · 3 comments
Closed

EventTarget interface not generic #3599

carlpaten opened this issue Jun 22, 2015 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@carlpaten
Copy link

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.

@RyanCavanaugh
Copy link
Member

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

Can you post some examples of how this happens? In general you should be able to provide a function that takes a more-specific type as an argument.

@mhegazy
Copy link
Contributor

mhegazy commented Jun 23, 2015

is this different from #299?

@danquirk
Copy link
Member

danquirk commented Jul 8, 2015

Gonna call this a dupe of the issue Mohamed mentioned unless we get more info.

@danquirk danquirk closed this as completed Jul 8, 2015
@danquirk danquirk added the Duplicate An existing issue was already created label Jul 8, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants