diff --git a/query/src/lib/query-client.ts b/query/src/lib/query-client.ts index 40a18df..3793cc5 100644 --- a/query/src/lib/query-client.ts +++ b/query/src/lib/query-client.ts @@ -14,12 +14,14 @@ import { FetchInfiniteQueryOptions, FetchQueryOptions, InfiniteData, + InfiniteQueryObserverOptions, QueryKey, + QueryObserverOptions, } from '@tanstack/query-core'; import { CreateBaseQueryOptions } from './base-query'; import { CreateInfiniteQueryOptions } from './infinite-query'; import { QUERY_CLIENT_OPTIONS } from './query-client-options'; -import { normalizeOptions, queryObserverOptions } from './query-options'; +import { normalizeOptions } from './query-options'; const QueryClientToken = new InjectionToken('QueryClient', { providedIn: 'root', @@ -123,10 +125,15 @@ export class QueryClient extends _QueryClient { TQueryKey >, ): Promise { - const baseOptions = queryObserverOptions(options); const defaultedOptions = normalizeOptions( this, - baseOptions, + options as QueryObserverOptions< + TQueryFnData, + TError, + TData, + TQueryFnData, + TQueryKey + >, this.#injector, ) as unknown as FetchQueryOptions< TQueryFnData, @@ -202,10 +209,16 @@ export class QueryClient extends _QueryClient { TPageParam >, ): Promise { - const baseOptions = queryObserverOptions(options); const defaultedOptions = normalizeOptions( this, - baseOptions, + options as QueryObserverOptions< + TQueryFnData, + TError, + TData, + TQueryFnData, + TQueryKey, + TPageParam + >, this.#injector, ) as unknown as FetchQueryOptions< TQueryFnData, @@ -267,10 +280,15 @@ export class QueryClient extends _QueryClient { TQueryKey >, ): Promise { - const baseOptions = queryObserverOptions(options); const defaultedOptions = normalizeOptions( this, - baseOptions, + options as QueryObserverOptions< + TQueryFnData, + TError, + TData, + TQueryFnData, + TQueryKey + >, this.#injector, ) as unknown as FetchQueryOptions< TQueryFnData, @@ -290,7 +308,7 @@ export class QueryClient extends _QueryClient { * * queryClient = injectQueryClient(); * - * const data = await queryClient.fetchInfiniteQuery({ queryKey, queryFn }) + * const data = await queryClient.fetchInfiniteQuery({ queryKey, queryFn, initialPageParam, getPreviousPageParam, getNextPageParam }) }) * */ override fetchInfiniteQuery< @@ -340,10 +358,16 @@ export class QueryClient extends _QueryClient { TPageParam >, ): Promise> { - const baseOptions = queryObserverOptions(options); const defaultedOptions = normalizeOptions( this, - baseOptions, + options as InfiniteQueryObserverOptions< + TQueryFnData, + TError, + TQueryFnData, + TQueryFnData, + TQueryKey, + TPageParam + >, this.#injector, ) as unknown as FetchInfiniteQueryOptions< TQueryFnData, @@ -363,7 +387,7 @@ export class QueryClient extends _QueryClient { * * queryClient = injectQueryClient(); * - * await queryClient.prefetchInfiniteQuery({ queryKey, queryFn }) + * await queryClient.prefetchInfiniteQuery({ queryKey, queryFn, initialPageParam, getPreviousPageParam, getNextPageParam }) * */ override prefetchInfiniteQuery< @@ -413,10 +437,16 @@ export class QueryClient extends _QueryClient { TPageParam >, ): Promise { - const baseOptions = queryObserverOptions(options); const defaultedOptions = normalizeOptions( this, - baseOptions, + options as InfiniteQueryObserverOptions< + TQueryFnData, + TError, + TQueryFnData, + TQueryFnData, + TQueryKey, + TPageParam + >, this.#injector, ) as unknown as FetchInfiniteQueryOptions< TQueryFnData, diff --git a/query/src/lib/query-options.ts b/query/src/lib/query-options.ts index 7e3b289..14f48c0 100644 --- a/query/src/lib/query-options.ts +++ b/query/src/lib/query-options.ts @@ -2,7 +2,6 @@ import { Injector, runInInjectionContext } from '@angular/core'; import type { DataTag, DefaultError, - InfiniteQueryObserverOptions, QueryClient, QueryFunctionContext, QueryKey, @@ -57,7 +56,6 @@ export function queryOptions< ): UndefinedInitialDataOptions & { queryKey: DataTag; }; - export function queryOptions< TQueryFnData = unknown, TError = DefaultError, @@ -68,7 +66,6 @@ export function queryOptions< ): DefinedInitialDataOptions & { queryKey: DataTag; }; - export function queryOptions< TQueryFnData = unknown, TError = DefaultError, @@ -98,56 +95,6 @@ export function queryOptions(options: unknown) { return options; } -export function queryObserverOptions< - TQueryFnData = unknown, - TError = DefaultError, - TData = TQueryFnData, - TQueryKey extends QueryKey = QueryKey, - TPageParam = never, ->( - options: CreateInfiniteQueryOptions< - TQueryFnData, - TError, - TData, - TQueryFnData, - TQueryKey, - TPageParam - >, -): InfiniteQueryObserverOptions< - TQueryFnData, - TError, - TQueryFnData, - TQueryFnData, - TQueryKey, - TPageParam ->; -export function queryObserverOptions< - TQueryFnData = unknown, - TError = DefaultError, - TData = TQueryFnData, - TQueryKey extends QueryKey = QueryKey, - TPageParam = never, ->( - options: CreateBaseQueryOptions< - TQueryFnData, - TError, - TData, - TQueryFnData, - TQueryKey, - TPageParam - >, -): QueryObserverOptions< - TQueryFnData, - TError, - TData, - TQueryFnData, - TQueryKey, - TPageParam ->; -export function queryObserverOptions(options: unknown) { - return options; -} - export function normalizeOptions< TQueryFnData, TError,