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

DOM lib doesn't have the concrete event signatures like the React synthetic event declared? #21825

Closed
zheeeng opened this issue Feb 9, 2018 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@zheeeng
Copy link

zheeeng commented Feb 9, 2018

TypeScript Version: 2.7.0

Search Terms:

Code

declare const $input: HTMLInputElement

// Property 'value' does not exist on type 'EventTarget'
$input.onchange = e => { console.log(e.target.value) }

Expected behavior:

The e.target be inferred as HTMLInputElement instead of EventTarget.

The HTMLInputElement could be signatured as below or other proposals:

interface HTMLElement<E> extends Element {
    onchange: (this: E, ev: Event) => any;
}

interface HTMLInputElement extends HTMLElement<HTMLInputElement> {
}

Actual behavior:

Error Property 'value' does not exist on type 'EventTarget'

Playground Link:
Playground

@mhegazy
Copy link
Contributor

mhegazy commented Feb 9, 2018

I think this is the same issue as #299, the request to make Event interface generic with its target as the argument.

@mhegazy mhegazy added the Duplicate An existing issue was already created label Feb 9, 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