Skip to content

Commit dc3e8c1

Browse files
committed
refactor: fix debounce function typings
1 parent 59487ac commit dc3e8c1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/utils/debounce.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
* @param { number } wait Time to wait before execut the function
66
* @param { boolean } immediate Param to define if the function will be executed immediately
77
*/
8-
const debounce = (func: (...args: any[]) => void, wait?: number, immediate?: boolean) => {
8+
const debounce = <T, A extends any[]>(
9+
func: (...args: A) => void,
10+
wait?: number,
11+
immediate?: boolean,
12+
) => {
913
let timeout: NodeJS.Timeout | null = null
1014

11-
return function debounced(this: typeof func, ...args: any[]) {
15+
return function debounced(this: T, ...args: A): void {
1216
const later = () => {
1317
timeout = null
1418
if (!immediate) {

0 commit comments

Comments
 (0)