diff --git a/packages/core/useAsyncState/index.ts b/packages/core/useAsyncState/index.ts index 6a7c978612e..8de1c33c482 100644 --- a/packages/core/useAsyncState/index.ts +++ b/packages/core/useAsyncState/index.ts @@ -2,12 +2,12 @@ import { noop, promiseTimeout } from '@vueuse/shared' import type { Ref, UnwrapRef } from 'vue-demi' import { ref, shallowRef } from 'vue-demi' -export interface UseAsyncStateReturn { +export interface UseAsyncStateReturn { state: Shallow extends true ? Ref : Ref> isReady: Ref isLoading: Ref error: Ref - execute: (delay?: number, ...args: any[]) => Promise + execute: (delay?: number, ...args: Params) => Promise } export interface UseAsyncStateOptions { @@ -74,11 +74,11 @@ export interface UseAsyncStateOptions { * @param initialState The initial state, used until the first evaluation finishes * @param options */ -export function useAsyncState( - promise: Promise | ((...args: any[]) => Promise), +export function useAsyncState( + promise: Promise | ((...args: Params) => Promise), initialState: Data, options?: UseAsyncStateOptions, -): UseAsyncStateReturn { +): UseAsyncStateReturn { const { immediate = true, delay = 0, @@ -104,7 +104,7 @@ export function useAsyncState( await promiseTimeout(delay) const _promise = typeof promise === 'function' - ? promise(...args) + ? promise(...args as Params) : promise try {