From 32e769fd0996ea1d26c4254908e6758ebd62e77a Mon Sep 17 00:00:00 2001 From: Christian Andolf Date: Fri, 28 Mar 2025 14:40:36 +0100 Subject: [PATCH] chore: debounce function is now typed to accommodate typed parameters in a callback --- apps/scandic-web/utils/debounce.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/scandic-web/utils/debounce.ts b/apps/scandic-web/utils/debounce.ts index 80eb13e96..6ada7d737 100644 --- a/apps/scandic-web/utils/debounce.ts +++ b/apps/scandic-web/utils/debounce.ts @@ -1,9 +1,11 @@ -export function debounce(func: Function, delay = 300) { +export function debounce( + func: (...args: Params) => any, + delay = 300 +) { let debounceTimer: ReturnType - return function () { - // @ts-expect-error this in TypeScript + + return function (this: U, ...args: Parameters) { const context = this - const args = arguments clearTimeout(debounceTimer) debounceTimer = setTimeout(() => func.apply(context, args), delay) }