From f6748db8f280f8f2ef358ed84252997880484954 Mon Sep 17 00:00:00 2001 From: Vadim Kiryanov <89611560+vadimkiryanov@users.noreply.github.com> Date: Tue, 1 Aug 2023 12:04:08 +0600 Subject: [PATCH] Update use-window-event.ts Typed custom event. Previously, when passing a custom event, the type was any, but now it is considered as Event. Listner typing bug fixed --- src/mantine-hooks/src/use-window-event/use-window-event.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/mantine-hooks/src/use-window-event/use-window-event.ts b/src/mantine-hooks/src/use-window-event/use-window-event.ts index 379bb3a6dbd..47e2c72f814 100644 --- a/src/mantine-hooks/src/use-window-event/use-window-event.ts +++ b/src/mantine-hooks/src/use-window-event/use-window-event.ts @@ -1,10 +1,8 @@ import { useEffect } from 'react'; -export function useWindowEvent( +function useWindowEvent>( type: K, - listener: K extends keyof WindowEventMap - ? (this: Window, ev: WindowEventMap[K]) => void - : (this: Window, ev: CustomEvent) => void, + listener: K extends keyof WindowEventMap ? (this: Window, ev: WindowEventMap[K]) => void : EventListener, options?: boolean | AddEventListenerOptions ) { useEffect(() => {