type DebounceFunction = (...args: Array) => void; let timeoutId: NodeJS.Timeout; export const debounce = ( func: T, delay: number ): ((...args: Parameters) => void) => (...args: Parameters) => { clearTimeout(timeoutId); timeoutId = setTimeout(() => { func(...args); }, delay); };