Open History to see the last commit
1import type {
2 DataTag,
3 DefaultError,
4 InfiniteData,
5 InitialDataFunction,
6 NonUndefinedGuard,
7 OmitKeyof,
8 QueryKey,
9 SkipToken,
10} from '@tanstack/query-core'
11import type { CreateInfiniteQueryOptions } from './types'
12β
13export type UndefinedInitialDataInfiniteOptions<
14 TQueryFnData,
15 TError = DefaultError,
16 TData = InfiniteData<TQueryFnData>,
17 TQueryKey extends QueryKey = QueryKey,
18 TPageParam = unknown,
19> = CreateInfiniteQueryOptions<
20 TQueryFnData,
21 TError,
22 TData,
23 TQueryKey,
24 TPageParam
25> & {
26 initialData?:
27 | undefined
28 | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
29 | InitialDataFunction<
30 NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
31 >
32}
33β
34export type UnusedSkipTokenInfiniteOptions<
35 TQueryFnData,
36 TError = DefaultError,
37 TData = InfiniteData<TQueryFnData>,
38 TQueryKey extends QueryKey = QueryKey,
39 TPageParam = unknown,
40> = OmitKeyof<
41 CreateInfiniteQueryOptions<
42 TQueryFnData,
43 TError,
44 TData,
45 TQueryKey,
46 TPageParam
47 >,
48 'queryFn'
49> & {
50 queryFn?: Exclude<
51 CreateInfiniteQueryOptions<
52 TQueryFnData,
53 TError,
54 TData,
55 TQueryKey,
56 TPageParam
57 >['queryFn'],
58 SkipToken | undefined
59 >
60}
61β
62export type DefinedInitialDataInfiniteOptions<
63 TQueryFnData,
64 TError = DefaultError,
65 TData = InfiniteData<TQueryFnData>,
66 TQueryKey extends QueryKey = QueryKey,
67 TPageParam = unknown,
68> = CreateInfiniteQueryOptions<
69 TQueryFnData,
70 TError,
71 TData,
72 TQueryKey,
73 TPageParam
74> & {
75 initialData:
76 | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
77 | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)
78 | undefined
79}
80β
81/**
82 * Allows to share and re-use infinite query options in a type-safe way.
83 *
84 * The `queryKey` will be tagged with the type from `queryFn`.
85 * @param options - The infinite query options to tag with the type from `queryFn`.
86 * @returns The tagged infinite query options.
87 * @public
88 */
89export function infiniteQueryOptions<
90 TQueryFnData,
91 TError = DefaultError,
92 TData = InfiniteData<TQueryFnData>,
93 TQueryKey extends QueryKey = QueryKey,
94 TPageParam = unknown,
95>(
96 options: DefinedInitialDataInfiniteOptions<
97 TQueryFnData,
98 TError,
99 TData,
100 TQueryKey,
101 TPageParam
102 >,
103): DefinedInitialDataInfiniteOptions<
104 TQueryFnData,
105 TError,
106 TData,
107 TQueryKey,
108 TPageParam
109> & {
110 queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
111}
112β
113/**
114 * Allows to share and re-use infinite query options in a type-safe way.
115 *
116 * The `queryKey` will be tagged with the type from `queryFn`.
117 * @param options - The infinite query options to tag with the type from `queryFn`.
118 * @returns The tagged infinite query options.
119 * @public
120 */
121export function infiniteQueryOptions<
122 TQueryFnData,
123 TError = DefaultError,
124 TData = InfiniteData<TQueryFnData>,
125 TQueryKey extends QueryKey = QueryKey,
126 TPageParam = unknown,
127>(
128 options: UnusedSkipTokenInfiniteOptions<
129 TQueryFnData,
130 TError,
131 TData,
132 TQueryKey,
133 TPageParam
134 >,
135): UnusedSkipTokenInfiniteOptions<
136 TQueryFnData,
137 TError,
138 TData,
139 TQueryKey,
140 TPageParam
141> & {
142 queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
143}
144β
145/**
146 * Allows to share and re-use infinite query options in a type-safe way.
147 *
148 * The `queryKey` will be tagged with the type from `queryFn`.
149 * @param options - The infinite query options to tag with the type from `queryFn`.
150 * @returns The tagged infinite query options.
151 * @public
152 */
153export function infiniteQueryOptions<
154 TQueryFnData,
155 TError = DefaultError,
156 TData = InfiniteData<TQueryFnData>,
157 TQueryKey extends QueryKey = QueryKey,
158 TPageParam = unknown,
159>(
160 options: UndefinedInitialDataInfiniteOptions<
161 TQueryFnData,
162 TError,
163 TData,
164 TQueryKey,
165 TPageParam
166 >,
167): UndefinedInitialDataInfiniteOptions<
168 TQueryFnData,
169 TError,
170 TData,
171 TQueryKey,
172 TPageParam
173> & {
174 queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
175}
176β
177/**
178 * Allows to share and re-use infinite query options in a type-safe way.
179 *
180 * The `queryKey` will be tagged with the type from `queryFn`.
181 * @param options - The infinite query options to tag with the type from `queryFn`.
182 * @returns The tagged infinite query options.
183 * @public
184 */
185export function infiniteQueryOptions(options: unknown) {
186 return options
187}