From b0bba93cf6b7b391d1731bf146f4cd64b23755ec Mon Sep 17 00:00:00 2001 From: "Xavier(Home)" Date: Tue, 20 May 2025 22:20:44 +0800 Subject: [PATCH] fixed an error in panorama event handlers --- packages/panorama-types/types/api.d.ts | 2 +- packages/panorama-types/types/panorama-events.d.ts | 10 +++++----- test/panorama/panorama-events.ts | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/panorama-types/types/api.d.ts b/packages/panorama-types/types/api.d.ts index f13a82b..85b8aea 100644 --- a/packages/panorama-types/types/api.d.ts +++ b/packages/panorama-types/types/api.d.ts @@ -38,7 +38,7 @@ declare namespace PanoramaEvents { : TUntyped; type InferPanoramaCallback = T extends PanoramaEventName ? PanoramaEvent[T] extends (...args: infer P) => void - ? (...args: P) => void + ? ((...args: P) => void) | ((...args: [PanelBase, ...P]) => void) : (...args: any[]) => void : (...args: any[]) => void; } diff --git a/packages/panorama-types/types/panorama-events.d.ts b/packages/panorama-types/types/panorama-events.d.ts index ea936ff..26ca177 100644 --- a/packages/panorama-types/types/panorama-events.d.ts +++ b/packages/panorama-types/types/panorama-events.d.ts @@ -351,9 +351,9 @@ declare interface PanoramaEvent { /** * Drag events */ - DragStart(panel: PanelBase, settings: DragSettings): void; - DragEnter(panel: PanelBase, displayPanel: PanelBase): void; - DragLeave(panel: PanelBase, displayPanel: PanelBase): void; - DragDrop(panel: PanelBase, displayPanel: PanelBase): void; - DragEnd(panel: PanelBase, displayPanel: PanelBase): void; + DragStart(settings: DragSettings): void; + DragEnter(displayPanel: PanelBase): void; + DragLeave(displayPanel: PanelBase): void; + DragDrop(displayPanel: PanelBase): void; + DragEnd(displayPanel: PanelBase): void; } diff --git a/test/panorama/panorama-events.ts b/test/panorama/panorama-events.ts index 67fc177..025b67c 100644 --- a/test/panorama/panorama-events.ts +++ b/test/panorama/panorama-events.ts @@ -32,8 +32,9 @@ $.RegisterEventHandler('DragStart', $('#test'), (panelId, settings, badParam) => $.RegisterEventHandler('UnknownEvent', $('#test'), () => {}); $.RegisterForUnhandledEvent('DOTAHUDBuffClicked', () => {}); -// @ts-expect-error $.RegisterForUnhandledEvent('DOTAHUDBuffClicked', (panel) => {}); +// @ts-expect-error +$.RegisterForUnhandledEvent('DOTAHUDBuffClicked', (panel, badParam) => {}); // users can define their own events and parameters. declare global {