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] 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 5963fa9..2cc0675 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); }