export default function debounce void>( func: T, wait: number, ): T { let timeout: ReturnType | null = null return function (this: any, ...args: Parameters) { if (timeout !== null) { clearTimeout(timeout) } timeout = setTimeout(() => func.apply(this, args), wait) } as T }