Re-added typed event target

This commit is contained in:
Bertie690 2025-07-25 13:34:22 -04:00
parent 1c73b7c269
commit 54ec5904f0

View File

@ -0,0 +1,17 @@
/**
* Interface restricting the events emitted by an {@linkcode EventTarget} to a certain kind of {@linkcode Event}.
* @typeParam T - The type to restrict the interface's access; must extend from {@linkcode Event}
*/
export interface TypedEventTarget<T extends Event = never> extends EventTarget {
dispatchEvent(event: T): boolean;
addEventListener(
event: T["type"],
callback: EventListenerOrEventListenerObject | null,
options?: AddEventListenerOptions | boolean,
): void;
removeEventListener(
type: T["type"],
callback: EventListenerOrEventListenerObject | null,
options?: EventListenerOptions | boolean,
): void;
}