From 54ec5904f0267d48f06b91c80f91b9f362cc9659 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Fri, 25 Jul 2025 13:34:22 -0400 Subject: [PATCH] Re-added typed event target --- src/@types/typed-event-target.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/@types/typed-event-target.ts diff --git a/src/@types/typed-event-target.ts b/src/@types/typed-event-target.ts new file mode 100644 index 00000000000..2c38a6812d6 --- /dev/null +++ b/src/@types/typed-event-target.ts @@ -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 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; +}