Skip to content

Commit

Permalink
backport #4066
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Apr 27, 2024
1 parent aba4a42 commit 6e37721
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1075,9 +1075,9 @@ export namespace JSXInternal {
export type TargetedPictureInPictureEvent<Target extends EventTarget> =
TargetedEvent<Target, PictureInPictureEvent>;

export interface EventHandler<E extends TargetedEvent> {
(this: void, event: E): void;
}
export type EventHandler<E extends TargetedEvent> = {
bivarianceHack(event: E): void;
}['bivarianceHack'];

export type AnimationEventHandler<Target extends EventTarget> = EventHandler<
TargetedAnimationEvent<Target>
Expand Down
13 changes: 13 additions & 0 deletions test/ts/Component-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,16 @@ describe('Component', () => {
});
});
});

class Button extends Component {
handleClick(this: HTMLButtonElement, event: MouseEvent) {
event.preventDefault();
if (event.target instanceof HTMLElement) {
console.log(event.target.localName);
}
}

render() {
return <button onClick={this.handleClick}>{this.props.children}</button>;
}
}

0 comments on commit 6e37721

Please sign in to comment.