-
Notifications
You must be signed in to change notification settings - Fork 13k
Description
Line 5715 in da5ff57
"input": Event; |
Hi I am wondering why type of 'input'
event type is a Event
type (I thought it should be InputEvent
)?
I came across on this problem doing this:
interface OnInputTextFieldListenerProps extends BaseTextFieldListenerProps {
eventName: Extract<keyof GlobalEventHandlersEventMap, 'input'>;
callback(e?: InputEvent): void;
}
if (isOnInputTextFieldProps(listenerProps)) {
this.input.addEventListener<'input'>(listenerProps.eventName, listenerProps.callback.bind(this));
}
And now I am getting this error:
TS2345: Argument of type '(e?: InputEvent | undefined) => void' is not assignable to parameter of type '(this: HTMLInputElement, ev: Event) => any'.
Which is absolutely correct.
But why GlobalEventHandlersEventMap
'input'
is typed as Event
instead of InputEvent
. If MDN documentation says that GlobalEventHandlers.oninput
interface is InputEvent
. oninput
is probalby equivalent of typescript input
. I think like that because in MDN docs every key of GlobalEventHandlers
interface starts with on
.
You can find this GlobalEventHandlersEventMap
interface here lib.dom.d.ts - L:5715 at line 5715
.
I also created a question at StackOverflow - Why 'input' event has
Event
type of event instead ofInputEvent