refactor(editor): Fix type errors in ResourcesListLayout.vue (no-changelog) (#9461)
This commit is contained in:
@@ -6,13 +6,16 @@ export interface DebounceOptions {
|
||||
trailing?: boolean;
|
||||
}
|
||||
|
||||
export type DebouncedFunction<R = void> = (...args: unknown[]) => R;
|
||||
export type DebouncedFunction<Args extends unknown[] = unknown[], R = void> = (...args: Args) => R;
|
||||
|
||||
export function useDebounce() {
|
||||
// Create a ref for the WeakMap to store debounced functions.
|
||||
const debounceCache = ref(new WeakMap<DebouncedFunction<unknown>, DebouncedFunction<unknown>>());
|
||||
const debounceCache = ref(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
new WeakMap<DebouncedFunction<any, any>, DebouncedFunction<any, any>>(),
|
||||
);
|
||||
|
||||
const debounce = <T extends DebouncedFunction<ReturnType<T>>>(
|
||||
const debounce = <T extends DebouncedFunction<Parameters<T>, ReturnType<T>>>(
|
||||
fn: T,
|
||||
options: DebounceOptions,
|
||||
): T => {
|
||||
@@ -24,7 +27,7 @@ export function useDebounce() {
|
||||
// If a debounced version is not found, create one and store it in the WeakMap.
|
||||
if (debouncedFn === undefined) {
|
||||
debouncedFn = _debounce(
|
||||
async (...args: unknown[]) => {
|
||||
async (...args: Parameters<T>) => {
|
||||
return fn(...args);
|
||||
},
|
||||
debounceTime,
|
||||
@@ -37,7 +40,7 @@ export function useDebounce() {
|
||||
return debouncedFn as T;
|
||||
};
|
||||
|
||||
const callDebounced = <T extends DebouncedFunction<ReturnType<T>>>(
|
||||
const callDebounced = <T extends DebouncedFunction<Parameters<T>, ReturnType<T>>>(
|
||||
fn: T,
|
||||
options: DebounceOptions,
|
||||
...inputParameters: Parameters<T>
|
||||
|
||||
Reference in New Issue
Block a user