Describe the bug
The type of this onChange events is not event.currentTarget as the type definition implies:
|
interface EventHandler<E extends TargetedEvent> { |
|
/** |
|
* The `this` keyword always points to the DOM element the event handler |
|
* was invoked on. See: https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Event_handlers#Event_handlers_parameters_this_binding_and_the_return_value |
|
*/ |
|
(this: E['currentTarget'], event: E): void; |
Also implied in this test:
|
// Test `this` binding on event handlers |
|
function onHandler(this: HTMLInputElement, event: any) { |
|
return this.value; |
|
} |
|
const foo = <input onChange={onHandler} />; |
To Reproduce
https://codesandbox.io/embed/ancient-tree-6kj30?expanddevtools=1
Steps to reproduce the behavior:
- Click on the input checkbox
- See error in the console
Expected behavior
The type of this should be the same as event.currentTarget
Describe the bug
The type of
thisonChange events is notevent.currentTargetas the type definition implies:preact/src/jsx.d.ts
Lines 368 to 373 in c7f57db
Also implied in this test:
preact/test/ts/Component-test.tsx
Lines 5 to 9 in c7f57db
To Reproduce
https://codesandbox.io/embed/ancient-tree-6kj30?expanddevtools=1
Steps to reproduce the behavior:
Expected behavior
The type of
thisshould be the same asevent.currentTarget