diff --git a/packages/hooks/src/useDebounceFn/index.ts b/packages/hooks/src/useDebounceFn/index.ts index 06c04152ec..e99871c443 100644 --- a/packages/hooks/src/useDebounceFn/index.ts +++ b/packages/hooks/src/useDebounceFn/index.ts @@ -19,10 +19,10 @@ function useDebounceFn(fn: T, options?: DebounceOptions) { const debounced = useMemo( () => - debounce( - ((...args: any[]) => { + debounce( + ((...args: Parameters): ReturnType => { return fnRef.current(...args); - }) as T, + }), wait, options, ), @@ -34,7 +34,7 @@ function useDebounceFn(fn: T, options?: DebounceOptions) { }); return { - run: debounced as unknown as T, + run: debounced, cancel: debounced.cancel, flush: debounced.flush, }; diff --git a/packages/hooks/src/useThrottleFn/index.ts b/packages/hooks/src/useThrottleFn/index.ts index ad427137f0..3fe4ad354f 100644 --- a/packages/hooks/src/useThrottleFn/index.ts +++ b/packages/hooks/src/useThrottleFn/index.ts @@ -19,10 +19,10 @@ function useThrottleFn(fn: T, options?: ThrottleOptions) { const throttled = useMemo( () => - throttle( - ((...args: any[]) => { + throttle( + ((...args: Parameters): ReturnType => { return fnRef.current(...args); - }) as T, + }), wait, options, ), @@ -34,7 +34,7 @@ function useThrottleFn(fn: T, options?: ThrottleOptions) { }); return { - run: throttled as unknown as T, + run: throttled, cancel: throttled.cancel, flush: throttled.flush, };