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

Support InputEvent interface in libs #29441

Closed
Christian24 opened this issue Jan 16, 2019 · 4 comments
Closed

Support InputEvent interface in libs #29441

Christian24 opened this issue Jan 16, 2019 · 4 comments

Comments

@Christian24
Copy link

Christian24 commented Jan 16, 2019

Search Terms

input event
InputEvent

Suggestion

TypeScript so far does not have a type definition of InputEvent (https://developer.mozilla.org/en-US/docs/Web/API/InputEvent). Even though there are some bugs concerning browser support, I would still say it is supported widely enough (https://caniuse.com/#feat=input-event) to be part of TypeScript's libs. So, far there only is a type definition available through @types/dom-inputevent

Use Cases

Working with input elements in HTML5. It's a feature of HTML5 and thus should be supported.

Examples

(event: InputEvent) => this.value = event.currentTarget.value;

Checklist

My suggestion meets these guidelines:

  • [x ] This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • [ x] This wouldn't change the runtime behavior of existing JavaScript code
  • [x ] This could be implemented without emitting different JS based on the types of the expressions
  • [x ] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • [ x] This feature would agree with the rest of TypeScript's Design Goals.
@RyanCavanaugh
Copy link
Member

We don't add definitions into the built-in lib.dom until they leave the Experimental phase.

@Christian24
Copy link
Author

Okay, thanks. I understand. However, in this case I do not really agree, InputEvent is available since IE9, so web developers have had lots of time to use it, so it is desirable to have typing support for it.

@akoidan
Copy link

akoidan commented Oct 15, 2019

That's unfortunate because code like this breaks everything in Edge 15:
tsconfig.json:

{
  "experimentalDecorators": true,
}

index.ts:

class A {
  a(b: InputEvent) {
  }
}

Not that obvious that typings could break a class declaration... Also, note that bundlers like webpack would pack declarations to main method, which would throw an error immediately making customers unhappy :(

Here's the related issue.

@michahell
Copy link

Why is this something that is in 'Experimental' phase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants