Skip to content

Commit 11cdca1

Browse files
authored
fixed an error in panorama event handlers (#42)
1 parent d578d09 commit 11cdca1

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

packages/panorama-types/types/api.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ declare namespace PanoramaEvents {
3838
: TUntyped;
3939
type InferPanoramaCallback<T extends string> = T extends PanoramaEventName
4040
? PanoramaEvent[T] extends (...args: infer P) => void
41-
? (...args: P) => void
41+
? ((...args: P) => void) | ((...args: [PanelBase, ...P]) => void)
4242
: (...args: any[]) => void
4343
: (...args: any[]) => void;
4444
}

packages/panorama-types/types/panorama-events.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,9 @@ declare interface PanoramaEvent {
351351
/**
352352
* Drag events
353353
*/
354-
DragStart(panel: PanelBase, settings: DragSettings): void;
355-
DragEnter(panel: PanelBase, displayPanel: PanelBase): void;
356-
DragLeave(panel: PanelBase, displayPanel: PanelBase): void;
357-
DragDrop(panel: PanelBase, displayPanel: PanelBase): void;
358-
DragEnd(panel: PanelBase, displayPanel: PanelBase): void;
354+
DragStart(settings: DragSettings): void;
355+
DragEnter(displayPanel: PanelBase): void;
356+
DragLeave(displayPanel: PanelBase): void;
357+
DragDrop(displayPanel: PanelBase): void;
358+
DragEnd(displayPanel: PanelBase): void;
359359
}

test/panorama/panorama-events.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ $.RegisterEventHandler('DragStart', $('#test'), (panelId, settings, badParam) =>
3232
$.RegisterEventHandler('UnknownEvent', $('#test'), () => {});
3333

3434
$.RegisterForUnhandledEvent('DOTAHUDBuffClicked', () => {});
35-
// @ts-expect-error
3635
$.RegisterForUnhandledEvent('DOTAHUDBuffClicked', (panel) => {});
36+
// @ts-expect-error
37+
$.RegisterForUnhandledEvent('DOTAHUDBuffClicked', (panel, badParam) => {});
3738

3839
// users can define their own events and parameters.
3940
declare global {

0 commit comments

Comments
 (0)