From 03c6879d6fa3a950022abd3038ccd4d0644a6e14 Mon Sep 17 00:00:00 2001 From: Kuesung Park Date: Wed, 1 Apr 2026 15:47:05 +0900 Subject: [PATCH 1/2] refactor(core): narrow types in debounce utility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace `any` with precise types in debounce.ts: - `any[]` → `unknown[]` in generic constraints - `any` → `ThisParameterType | undefined` for pendingThis - `this: any` → `this: ThisParameterType` in debounced function - Remove unnecessary eslint-disable comment --- packages/core/src/hooks/useDebounce/debounce.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/core/src/hooks/useDebounce/debounce.ts b/packages/core/src/hooks/useDebounce/debounce.ts index 417f483c..c67eaee8 100644 --- a/packages/core/src/hooks/useDebounce/debounce.ts +++ b/packages/core/src/hooks/useDebounce/debounce.ts @@ -1,7 +1,6 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ // Simplified version of https://github.com/toss/es-toolkit/blob/main/src/function/debounce.ts -export type DebouncedFunction void> = { +export type DebouncedFunction void> = { (...args: Parameters): void; cancel: () => void; }; @@ -17,12 +16,12 @@ type DebounceOptions = { edges?: Array<'leading' | 'trailing'>; }; -export function debounce void>( +export function debounce void>( func: F, debounceMs: number, { edges = ['leading', 'trailing'] }: DebounceOptions = {} ): DebouncedFunction { - let pendingThis: any = undefined; + let pendingThis: ThisParameterType | undefined = undefined; let pendingArgs: Parameters | null = null; const leading = edges != null && edges.includes('leading'); @@ -71,7 +70,7 @@ export function debounce void>( pendingArgs = null; }; - const debounced = function (this: any, ...args: Parameters) { + const debounced = function (this: ThisParameterType, ...args: Parameters) { // eslint-disable-next-line @typescript-eslint/no-this-alias pendingThis = this; pendingArgs = args; From 05059cbe02ae2cf37e040975dd7d3050d76f1499 Mon Sep 17 00:00:00 2001 From: Kuesung Park Date: Wed, 1 Apr 2026 15:52:29 +0900 Subject: [PATCH 2/2] refactor(core): keep `any[]` in generic constraint with inline eslint-disable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `any[]` is required for generic function constraints due to parameter contravariance — `unknown[]` rejects callbacks with specific param types. --- packages/core/src/hooks/useDebounce/debounce.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core/src/hooks/useDebounce/debounce.ts b/packages/core/src/hooks/useDebounce/debounce.ts index c67eaee8..8263c211 100644 --- a/packages/core/src/hooks/useDebounce/debounce.ts +++ b/packages/core/src/hooks/useDebounce/debounce.ts @@ -1,6 +1,7 @@ // Simplified version of https://github.com/toss/es-toolkit/blob/main/src/function/debounce.ts -export type DebouncedFunction void> = { +// eslint-disable-next-line @typescript-eslint/no-explicit-any -- generic function constraint requires `any[]` due to parameter contravariance +export type DebouncedFunction void> = { (...args: Parameters): void; cancel: () => void; }; @@ -16,7 +17,8 @@ type DebounceOptions = { edges?: Array<'leading' | 'trailing'>; }; -export function debounce void>( +// eslint-disable-next-line @typescript-eslint/no-explicit-any -- generic function constraint requires `any[]` due to parameter contravariance +export function debounce void>( func: F, debounceMs: number, { edges = ['leading', 'trailing'] }: DebounceOptions = {}