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

Extend Event interfaces with Element target #21622

Closed
NN--- opened this issue Feb 5, 2018 · 2 comments
Closed

Extend Event interfaces with Element target #21622

NN--- opened this issue Feb 5, 2018 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@NN---
Copy link

NN--- commented Feb 5, 2018

Events handlers in several interfaces such as Window, Document and so on can be safely typed with 'target: Element' instead of of 'target: EventTarget'

Before:

interface Event { target: EventTarget; }
interface UIEvent extends Event { ... }
interface MouseEvent extends UIEvent { ... }

interface DocumentEventMap extends GlobalEventHandlersEventMap {
 "click": MouseEvent;
}

After:

interface Event<Target = EventTarget>{ target: Target; }
interface UIEvent<Target = EventTarget> extends Event<Target> {  }
interface MouseEvent<Target = EventTarget> extends UIEvent<Target> { }

interface DocumentEventMap extends GlobalEventHandlersEventMap {
 "click": MouseEvent<Element>
}

Expected behavior:
Type of event.target should be 'Element' in relevant event handlers.

Actual behavior:
Type is always EventTarget which requires type assertions.

@mhegazy
Copy link
Contributor

mhegazy commented Feb 12, 2018

Duplicate of #299

@mhegazy mhegazy marked this as a duplicate of #299 Feb 12, 2018
@mhegazy mhegazy added the Duplicate An existing issue was already created label Feb 12, 2018
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 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

3 participants