From 0a0ab44058e61c8f80eae00b81e155e33cd45967 Mon Sep 17 00:00:00 2001 From: TaroSunn Date: Mon, 12 Jun 2023 20:38:23 +0800 Subject: [PATCH] types: 'this' issue in debounce function --- src/editor/utils/index.ts | 3 +-- src/utils/index.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/editor/utils/index.ts b/src/editor/utils/index.ts index ac3de24..e6c9664 100644 --- a/src/editor/utils/index.ts +++ b/src/editor/utils/index.ts @@ -1,11 +1,10 @@ export function debounce(func: Function, delay: number) { let timer: number - return function (...args: any) { + return function (this: any, ...args: any[]) { if (timer) { window.clearTimeout(timer) } timer = window.setTimeout(() => { - // @ts-ignore func.apply(this, args) }, delay) } diff --git a/src/utils/index.ts b/src/utils/index.ts index 90575da..acce137 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,11 +1,10 @@ export function debounce(func: Function, delay: number) { let timer: number - return function (...args: any) { + return function (this: any, ...args: any[]) { if (timer) { window.clearTimeout(timer) } timer = window.setTimeout(() => { - // @ts-ignore func.apply(this, args) }, delay) }