diff --git a/packages/vue-query/src/queryOptions.ts b/packages/vue-query/src/queryOptions.ts index 1221222e3c..c37a097aa9 100644 --- a/packages/vue-query/src/queryOptions.ts +++ b/packages/vue-query/src/queryOptions.ts @@ -1,8 +1,10 @@ import type { DataTag, DefaultError, QueryKey } from '@tanstack/query-core' import type { DefinedInitialQueryOptions, + NonUndefinedGuard, UndefinedInitialQueryOptions, } from './useQuery' +import type { UnwrapRef } from 'vue-demi' export function queryOptions< TQueryFnData = unknown, @@ -11,7 +13,7 @@ export function queryOptions< TQueryKey extends QueryKey = QueryKey, >( options: UndefinedInitialQueryOptions, -): UndefinedInitialQueryOptions & { +): UnwrapRef> & { queryKey: DataTag } @@ -22,8 +24,10 @@ export function queryOptions< TQueryKey extends QueryKey = QueryKey, >( options: DefinedInitialQueryOptions, -): DefinedInitialQueryOptions & { - queryKey: DataTag +): UnwrapRef> & { + queryKey: DataTag; + initialData: | NonUndefinedGuard + | (() => NonUndefinedGuard); } export function queryOptions(options: unknown) { diff --git a/packages/vue-query/src/useQuery.ts b/packages/vue-query/src/useQuery.ts index af3f1ea31d..65565aa4ab 100644 --- a/packages/vue-query/src/useQuery.ts +++ b/packages/vue-query/src/useQuery.ts @@ -15,7 +15,7 @@ import type { } from './types' import type { QueryClient } from './queryClient' -type NonUndefinedGuard = T extends undefined ? never : T +export type NonUndefinedGuard = T extends undefined ? never : T export type UseQueryOptions< TQueryFnData = unknown,