Skip to content

Commit 04920c0

Browse files
committed
feat(useThrottleFn): support ts4.5 types
1 parent 54d13ef commit 04920c0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/useThrottleFn.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default function useThrottleFn<T extends any[]>(
3030
const timer = useRef<ReturnType<typeof setTimeout>>();
3131
const fnRef = useRef(fn);
3232
const optionsRef = useRef<ThrottleFnOptions | undefined>(options);
33-
const currentArgs = useRef<any>();
33+
const currentArgs = useRef<T>();
3434

3535
fnRef.current = fn;
3636
optionsRef.current = options;
@@ -55,7 +55,7 @@ export default function useThrottleFn<T extends any[]>(
5555
}, wait);
5656
} else {
5757
timer.current = setTimeout(() => {
58-
fnRef.current(...currentArgs.current);
58+
fnRef.current(...(currentArgs.current as T));
5959
timer.current = undefined;
6060
}, wait);
6161
}
@@ -69,7 +69,7 @@ export default function useThrottleFn<T extends any[]>(
6969
return;
7070
}
7171

72-
fnRef.current(...currentArgs.current);
72+
fnRef.current(...(currentArgs.current as T));
7373
cancel();
7474
}, [cancel]);
7575

0 commit comments

Comments
 (0)