From b597636db93348f06188430bad1f12a4e08e83b1 Mon Sep 17 00:00:00 2001 From: Mitchell <50689806+kyle1an@users.noreply.github.com> Date: Wed, 1 Jan 2025 11:43:02 +0800 Subject: [PATCH 1/2] fix(useRetimer): improve `timerId` typing --- src/use-retimer/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/use-retimer/index.ts b/src/use-retimer/index.ts index e9bf5476..5963fa9e 100644 --- a/src/use-retimer/index.ts +++ b/src/use-retimer/index.ts @@ -7,7 +7,7 @@ import { useCallback, useRef } from 'react'; export function useRetimer() { const timerIdRef = useRef(); - return useCallback((timerId?: number) => { + return useCallback((timerId?: number | ReturnType) => { if (typeof timerIdRef.current === 'number') { clearTimeout(timerIdRef.current); } From 24a54a1b8162cdac30c0a1a684f49fb1cb92931e Mon Sep 17 00:00:00 2001 From: Mitchell <50689806+kyle1an@users.noreply.github.com> Date: Wed, 1 Jan 2025 11:48:47 +0800 Subject: [PATCH 2/2] fix(useRetimer): improve timerId typing --- src/use-retimer/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/use-retimer/index.ts b/src/use-retimer/index.ts index 5963fa9e..2cc06755 100644 --- a/src/use-retimer/index.ts +++ b/src/use-retimer/index.ts @@ -3,11 +3,13 @@ import 'client-only'; import { useCallback, useRef } from 'react'; +type Timer = number | ReturnType; + /** @see https://foxact.skk.moe/use-retimer */ export function useRetimer() { - const timerIdRef = useRef(); + const timerIdRef = useRef(); - return useCallback((timerId?: number | ReturnType) => { + return useCallback((timerId?: Timer) => { if (typeof timerIdRef.current === 'number') { clearTimeout(timerIdRef.current); }