仓库指标
- Star
- (48,455 star)
- PR 合并指标
- (平均合并 6天 17小时) (30 天内合并 9 个 PR)
描述
# Bug Report
🔎 Search Terms
typescript input event
ts InputEvent
typescript addEventListener("input",
🕗 Version & Regression Information
I just found it today but verified it was present back to 3.3.3333
I also verified it existed on nightly
Please keep and fill in the line that best applies:
This is the behavior in every version I tried, and I reviewed the FAQ for entries about... I looked at entries about event listeners, HTML element types, and callbacks.
⏯ Playground Link
💻 Code
// Error on the typing of the event parameter
(null as any as HTMLInputElement).addEventListener("input", (e: InputEvent) => {});
(null as any as HTMLTextAreaElement).addEventListener("input", (e: InputEvent) => {});
🙁 Actual behavior
The sample code fails to compile because the input event is always typed as an Event, not InputEvent.
🙂 Expected behavior
For most elements, the callback event should be Event, but for <textarea> and <input>, it should be InputEvent.
For and elements that accept text input (type=text, type=tel, etc.), the interface is InputEvent; for others, the interface is Event.
According to the W3C spec, it should be InputEvent for any element that is contenteditable. I don't know that you can trigger an input event on other non-contenteditable elements so perhaps the event type can be made InputEvent, regardless of the element type it is called on.