Skip to content

Commit

Permalink
Update use-window-event.ts
Browse files Browse the repository at this point in the history
Typed custom event. Previously, when passing a custom event, the type was any, but now it is considered as Event.

Listner typing bug fixed
  • Loading branch information
vadimkiryanov authored Aug 1, 2023
1 parent cf0f85f commit f6748db
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/mantine-hooks/src/use-window-event/use-window-event.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { useEffect } from 'react';

export function useWindowEvent<K extends string = keyof WindowEventMap>(
function useWindowEvent<K extends string = keyof Exclude<WindowEventMap, string>>(
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(() => {
Expand Down

0 comments on commit f6748db

Please sign in to comment.