type Callback = (...args: Args) => void; export function debounce( callback: Callback, wait: number, ): Callback { let timeoutId: ReturnType; return (...args: Args) => { clearTimeout(timeoutId); timeoutId = setTimeout(() => callback(...args), wait); }; }