Skip to content

Commit

Permalink
Merge branch 'main' into reduce-stack-size
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Jul 12, 2023
2 parents cd92c39 + 2258d7d commit 6ac290c
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 @@ -1076,9 +1076,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 @@ -122,6 +122,19 @@ function Mapper() {
return [1, 2, 3].map(x => <MapperItem foo={x} key={x} />);
}

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>;
}
}

describe('Component', () => {
const component = new SimpleComponent({ initialName: 'da name' });

Expand Down

0 comments on commit 6ac290c

Please sign in to comment.