From 8de799365f2f599a2a26a6b7032ddfc67ec6bd9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Duhen?= Date: Tue, 12 Nov 2024 11:19:17 +0100 Subject: [PATCH 1/2] feat(EventDispatcher): expose protected listeners --- types/three/src/core/EventDispatcher.d.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/types/three/src/core/EventDispatcher.d.ts b/types/three/src/core/EventDispatcher.d.ts index 403dd1c2e..fa458e121 100644 --- a/types/three/src/core/EventDispatcher.d.ts +++ b/types/three/src/core/EventDispatcher.d.ts @@ -39,6 +39,27 @@ export type EventListener = ( * @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/EventDispatcher.js | Source} */ export class EventDispatcher { + /** + * Maps event types to the list of their listeners. + * Only initialized when a listener is added. + * Event type entries are created when their first listener is added. + * + * @example + * ```typescript + * type MyDisp = EventDispatcher<{ a: { b: number }, c: { d: string } }>; + * const disp = new MyDisp(); + * // typeof disp._listeners == + * // | undefined + * // | { + * // a?: EventListener<{ b: number }, 'a', this>[], + * // c?: EventListener<{ d: string }, 'c', this>[], + * // }; + * ``` + */ + protected _listeners?: { + [Type in Extract]?: EventListener[] + }; + /** * Creates {@link THREE.EventDispatcher | EventDispatcher} object. */ From 8980bc31a97fe9e13f51387784659efef87afd16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Duhen?= Date: Tue, 19 Nov 2024 15:43:27 +0100 Subject: [PATCH 2/2] fix(typo): add missing semicolon --- types/three/src/core/EventDispatcher.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/three/src/core/EventDispatcher.d.ts b/types/three/src/core/EventDispatcher.d.ts index fa458e121..6066a001b 100644 --- a/types/three/src/core/EventDispatcher.d.ts +++ b/types/three/src/core/EventDispatcher.d.ts @@ -57,7 +57,7 @@ export class EventDispatcher { * ``` */ protected _listeners?: { - [Type in Extract]?: EventListener[] + [Type in Extract]?: EventListener[]; }; /**