@tanstack/react-query 5.105.0 → 5.105.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/build/legacy/HydrationBoundary.cjs +2 -3
  2. package/build/legacy/HydrationBoundary.d.cts +0 -2
  3. package/build/legacy/HydrationBoundary.d.cts.map +1 -1
  4. package/build/legacy/HydrationBoundary.d.ts +0 -2
  5. package/build/legacy/HydrationBoundary.d.ts.map +1 -1
  6. package/build/legacy/HydrationBoundary.js +1 -2
  7. package/build/legacy/IsRestoringProvider.cjs +2 -3
  8. package/build/legacy/IsRestoringProvider.d.cts +0 -2
  9. package/build/legacy/IsRestoringProvider.d.cts.map +1 -1
  10. package/build/legacy/IsRestoringProvider.d.ts +0 -2
  11. package/build/legacy/IsRestoringProvider.d.ts.map +1 -1
  12. package/build/legacy/IsRestoringProvider.js +1 -2
  13. package/build/legacy/QueryClientProvider.cjs +2 -3
  14. package/build/legacy/QueryClientProvider.d.cts +0 -2
  15. package/build/legacy/QueryClientProvider.d.cts.map +1 -1
  16. package/build/legacy/QueryClientProvider.d.ts +0 -2
  17. package/build/legacy/QueryClientProvider.d.ts.map +1 -1
  18. package/build/legacy/QueryClientProvider.js +1 -2
  19. package/build/legacy/QueryErrorResetBoundary.cjs +2 -3
  20. package/build/legacy/QueryErrorResetBoundary.d.cts +1 -3
  21. package/build/legacy/QueryErrorResetBoundary.d.cts.map +1 -1
  22. package/build/legacy/QueryErrorResetBoundary.d.ts +1 -3
  23. package/build/legacy/QueryErrorResetBoundary.d.ts.map +1 -1
  24. package/build/legacy/QueryErrorResetBoundary.js +1 -2
  25. package/build/legacy/errorBoundaryUtils.cjs +2 -3
  26. package/build/legacy/errorBoundaryUtils.d.cts +0 -2
  27. package/build/legacy/errorBoundaryUtils.d.cts.map +1 -1
  28. package/build/legacy/errorBoundaryUtils.d.ts +0 -2
  29. package/build/legacy/errorBoundaryUtils.d.ts.map +1 -1
  30. package/build/legacy/errorBoundaryUtils.js +1 -2
  31. package/build/legacy/index.cjs +1 -2
  32. package/build/legacy/index.js +1 -2
  33. package/build/legacy/infiniteQueryOptions.cjs +1 -2
  34. package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
  35. package/build/legacy/infiniteQueryOptions.d.cts +16 -16
  36. package/build/legacy/infiniteQueryOptions.d.cts.map +1 -1
  37. package/build/legacy/infiniteQueryOptions.d.ts +16 -16
  38. package/build/legacy/infiniteQueryOptions.d.ts.map +1 -1
  39. package/build/legacy/infiniteQueryOptions.js +1 -2
  40. package/build/legacy/infiniteQueryOptions.js.map +1 -1
  41. package/build/legacy/mutationOptions.cjs +1 -2
  42. package/build/legacy/mutationOptions.d.cts +0 -2
  43. package/build/legacy/mutationOptions.d.cts.map +1 -1
  44. package/build/legacy/mutationOptions.d.ts +0 -2
  45. package/build/legacy/mutationOptions.d.ts.map +1 -1
  46. package/build/legacy/mutationOptions.js +1 -2
  47. package/build/legacy/queryOptions.cjs +1 -2
  48. package/build/legacy/queryOptions.cjs.map +1 -1
  49. package/build/legacy/queryOptions.d.cts +16 -15
  50. package/build/legacy/queryOptions.d.cts.map +1 -1
  51. package/build/legacy/queryOptions.d.ts +16 -15
  52. package/build/legacy/queryOptions.d.ts.map +1 -1
  53. package/build/legacy/queryOptions.js +1 -2
  54. package/build/legacy/queryOptions.js.map +1 -1
  55. package/build/legacy/{rolldown-runtime-VH7oDXx4.cjs → rolldown-runtime-CmQyd0Gu.cjs} +1 -2
  56. package/build/legacy/suspense.cjs +1 -2
  57. package/build/legacy/suspense.d.cts +0 -2
  58. package/build/legacy/suspense.d.cts.map +1 -1
  59. package/build/legacy/suspense.d.ts +0 -2
  60. package/build/legacy/suspense.d.ts.map +1 -1
  61. package/build/legacy/suspense.js +1 -2
  62. package/build/legacy/types.cjs +1 -2
  63. package/build/legacy/types.d.cts +0 -2
  64. package/build/legacy/types.d.cts.map +1 -1
  65. package/build/legacy/types.d.ts +0 -2
  66. package/build/legacy/types.d.ts.map +1 -1
  67. package/build/legacy/types.js +1 -2
  68. package/build/legacy/useBaseQuery.cjs +5 -6
  69. package/build/legacy/useBaseQuery.cjs.map +1 -1
  70. package/build/legacy/useBaseQuery.d.cts +0 -2
  71. package/build/legacy/useBaseQuery.d.cts.map +1 -1
  72. package/build/legacy/useBaseQuery.d.ts +0 -2
  73. package/build/legacy/useBaseQuery.d.ts.map +1 -1
  74. package/build/legacy/useBaseQuery.js +4 -5
  75. package/build/legacy/useBaseQuery.js.map +1 -1
  76. package/build/legacy/useInfiniteQuery.cjs +1 -2
  77. package/build/legacy/useInfiniteQuery.cjs.map +1 -1
  78. package/build/legacy/useInfiniteQuery.d.cts +2 -4
  79. package/build/legacy/useInfiniteQuery.d.cts.map +1 -1
  80. package/build/legacy/useInfiniteQuery.d.ts +2 -4
  81. package/build/legacy/useInfiniteQuery.d.ts.map +1 -1
  82. package/build/legacy/useInfiniteQuery.js +1 -2
  83. package/build/legacy/useInfiniteQuery.js.map +1 -1
  84. package/build/legacy/useIsFetching.cjs +2 -3
  85. package/build/legacy/useIsFetching.cjs.map +1 -1
  86. package/build/legacy/useIsFetching.d.cts +1 -3
  87. package/build/legacy/useIsFetching.d.cts.map +1 -1
  88. package/build/legacy/useIsFetching.d.ts +1 -3
  89. package/build/legacy/useIsFetching.d.ts.map +1 -1
  90. package/build/legacy/useIsFetching.js +1 -2
  91. package/build/legacy/useIsFetching.js.map +1 -1
  92. package/build/legacy/useMutation.cjs +2 -3
  93. package/build/legacy/useMutation.d.cts +0 -2
  94. package/build/legacy/useMutation.d.cts.map +1 -1
  95. package/build/legacy/useMutation.d.ts +0 -2
  96. package/build/legacy/useMutation.d.ts.map +1 -1
  97. package/build/legacy/useMutation.js +1 -2
  98. package/build/legacy/useMutationState.cjs +2 -3
  99. package/build/legacy/useMutationState.cjs.map +1 -1
  100. package/build/legacy/useMutationState.d.cts +1 -3
  101. package/build/legacy/useMutationState.d.cts.map +1 -1
  102. package/build/legacy/useMutationState.d.ts +1 -3
  103. package/build/legacy/useMutationState.d.ts.map +1 -1
  104. package/build/legacy/useMutationState.js +1 -2
  105. package/build/legacy/useMutationState.js.map +1 -1
  106. package/build/legacy/usePrefetchInfiniteQuery.cjs +1 -2
  107. package/build/legacy/usePrefetchInfiniteQuery.d.cts +0 -2
  108. package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
  109. package/build/legacy/usePrefetchInfiniteQuery.d.ts +0 -2
  110. package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
  111. package/build/legacy/usePrefetchInfiniteQuery.js +1 -2
  112. package/build/legacy/usePrefetchQuery.cjs +1 -2
  113. package/build/legacy/usePrefetchQuery.d.cts +0 -2
  114. package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
  115. package/build/legacy/usePrefetchQuery.d.ts +0 -2
  116. package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
  117. package/build/legacy/usePrefetchQuery.js +1 -2
  118. package/build/legacy/useQueries.cjs +4 -5
  119. package/build/legacy/useQueries.cjs.map +1 -1
  120. package/build/legacy/useQueries.d.cts +0 -2
  121. package/build/legacy/useQueries.d.cts.map +1 -1
  122. package/build/legacy/useQueries.d.ts +0 -2
  123. package/build/legacy/useQueries.d.ts.map +1 -1
  124. package/build/legacy/useQueries.js +3 -4
  125. package/build/legacy/useQueries.js.map +1 -1
  126. package/build/legacy/useQuery.cjs +1 -2
  127. package/build/legacy/useQuery.cjs.map +1 -1
  128. package/build/legacy/useQuery.d.cts +5 -7
  129. package/build/legacy/useQuery.d.cts.map +1 -1
  130. package/build/legacy/useQuery.d.ts +5 -7
  131. package/build/legacy/useQuery.d.ts.map +1 -1
  132. package/build/legacy/useQuery.js +1 -2
  133. package/build/legacy/useQuery.js.map +1 -1
  134. package/build/legacy/useSuspenseInfiniteQuery.cjs +1 -2
  135. package/build/legacy/useSuspenseInfiniteQuery.d.cts +0 -2
  136. package/build/legacy/useSuspenseInfiniteQuery.d.cts.map +1 -1
  137. package/build/legacy/useSuspenseInfiniteQuery.d.ts +0 -2
  138. package/build/legacy/useSuspenseInfiniteQuery.d.ts.map +1 -1
  139. package/build/legacy/useSuspenseInfiniteQuery.js +1 -2
  140. package/build/legacy/useSuspenseQueries.cjs +1 -2
  141. package/build/legacy/useSuspenseQueries.d.cts +0 -2
  142. package/build/legacy/useSuspenseQueries.d.cts.map +1 -1
  143. package/build/legacy/useSuspenseQueries.d.ts +0 -2
  144. package/build/legacy/useSuspenseQueries.d.ts.map +1 -1
  145. package/build/legacy/useSuspenseQueries.js +1 -2
  146. package/build/legacy/useSuspenseQuery.cjs +1 -2
  147. package/build/legacy/useSuspenseQuery.d.cts +0 -2
  148. package/build/legacy/useSuspenseQuery.d.cts.map +1 -1
  149. package/build/legacy/useSuspenseQuery.d.ts +0 -2
  150. package/build/legacy/useSuspenseQuery.d.ts.map +1 -1
  151. package/build/legacy/useSuspenseQuery.js +1 -2
  152. package/build/modern/HydrationBoundary.cjs +2 -3
  153. package/build/modern/HydrationBoundary.d.cts +0 -2
  154. package/build/modern/HydrationBoundary.d.cts.map +1 -1
  155. package/build/modern/HydrationBoundary.d.ts +0 -2
  156. package/build/modern/HydrationBoundary.d.ts.map +1 -1
  157. package/build/modern/HydrationBoundary.js +1 -2
  158. package/build/modern/IsRestoringProvider.cjs +2 -3
  159. package/build/modern/IsRestoringProvider.d.cts +0 -2
  160. package/build/modern/IsRestoringProvider.d.cts.map +1 -1
  161. package/build/modern/IsRestoringProvider.d.ts +0 -2
  162. package/build/modern/IsRestoringProvider.d.ts.map +1 -1
  163. package/build/modern/IsRestoringProvider.js +1 -2
  164. package/build/modern/QueryClientProvider.cjs +2 -3
  165. package/build/modern/QueryClientProvider.d.cts +0 -2
  166. package/build/modern/QueryClientProvider.d.cts.map +1 -1
  167. package/build/modern/QueryClientProvider.d.ts +0 -2
  168. package/build/modern/QueryClientProvider.d.ts.map +1 -1
  169. package/build/modern/QueryClientProvider.js +1 -2
  170. package/build/modern/QueryErrorResetBoundary.cjs +2 -3
  171. package/build/modern/QueryErrorResetBoundary.d.cts +1 -3
  172. package/build/modern/QueryErrorResetBoundary.d.cts.map +1 -1
  173. package/build/modern/QueryErrorResetBoundary.d.ts +1 -3
  174. package/build/modern/QueryErrorResetBoundary.d.ts.map +1 -1
  175. package/build/modern/QueryErrorResetBoundary.js +1 -2
  176. package/build/modern/errorBoundaryUtils.cjs +2 -3
  177. package/build/modern/errorBoundaryUtils.d.cts +0 -2
  178. package/build/modern/errorBoundaryUtils.d.cts.map +1 -1
  179. package/build/modern/errorBoundaryUtils.d.ts +0 -2
  180. package/build/modern/errorBoundaryUtils.d.ts.map +1 -1
  181. package/build/modern/errorBoundaryUtils.js +1 -2
  182. package/build/modern/index.cjs +1 -2
  183. package/build/modern/index.js +1 -2
  184. package/build/modern/infiniteQueryOptions.cjs +1 -2
  185. package/build/modern/infiniteQueryOptions.cjs.map +1 -1
  186. package/build/modern/infiniteQueryOptions.d.cts +16 -16
  187. package/build/modern/infiniteQueryOptions.d.cts.map +1 -1
  188. package/build/modern/infiniteQueryOptions.d.ts +16 -16
  189. package/build/modern/infiniteQueryOptions.d.ts.map +1 -1
  190. package/build/modern/infiniteQueryOptions.js +1 -2
  191. package/build/modern/infiniteQueryOptions.js.map +1 -1
  192. package/build/modern/mutationOptions.cjs +1 -2
  193. package/build/modern/mutationOptions.d.cts +0 -2
  194. package/build/modern/mutationOptions.d.cts.map +1 -1
  195. package/build/modern/mutationOptions.d.ts +0 -2
  196. package/build/modern/mutationOptions.d.ts.map +1 -1
  197. package/build/modern/mutationOptions.js +1 -2
  198. package/build/modern/queryOptions.cjs +1 -2
  199. package/build/modern/queryOptions.cjs.map +1 -1
  200. package/build/modern/queryOptions.d.cts +16 -15
  201. package/build/modern/queryOptions.d.cts.map +1 -1
  202. package/build/modern/queryOptions.d.ts +16 -15
  203. package/build/modern/queryOptions.d.ts.map +1 -1
  204. package/build/modern/queryOptions.js +1 -2
  205. package/build/modern/queryOptions.js.map +1 -1
  206. package/build/modern/{rolldown-runtime-VH7oDXx4.cjs → rolldown-runtime-CmQyd0Gu.cjs} +1 -2
  207. package/build/modern/suspense.cjs +1 -2
  208. package/build/modern/suspense.d.cts +0 -2
  209. package/build/modern/suspense.d.cts.map +1 -1
  210. package/build/modern/suspense.d.ts +0 -2
  211. package/build/modern/suspense.d.ts.map +1 -1
  212. package/build/modern/suspense.js +1 -2
  213. package/build/modern/types.cjs +1 -2
  214. package/build/modern/types.d.cts +0 -2
  215. package/build/modern/types.d.cts.map +1 -1
  216. package/build/modern/types.d.ts +0 -2
  217. package/build/modern/types.d.ts.map +1 -1
  218. package/build/modern/types.js +1 -2
  219. package/build/modern/useBaseQuery.cjs +5 -6
  220. package/build/modern/useBaseQuery.cjs.map +1 -1
  221. package/build/modern/useBaseQuery.d.cts +0 -2
  222. package/build/modern/useBaseQuery.d.cts.map +1 -1
  223. package/build/modern/useBaseQuery.d.ts +0 -2
  224. package/build/modern/useBaseQuery.d.ts.map +1 -1
  225. package/build/modern/useBaseQuery.js +4 -5
  226. package/build/modern/useBaseQuery.js.map +1 -1
  227. package/build/modern/useInfiniteQuery.cjs +1 -2
  228. package/build/modern/useInfiniteQuery.cjs.map +1 -1
  229. package/build/modern/useInfiniteQuery.d.cts +2 -4
  230. package/build/modern/useInfiniteQuery.d.cts.map +1 -1
  231. package/build/modern/useInfiniteQuery.d.ts +2 -4
  232. package/build/modern/useInfiniteQuery.d.ts.map +1 -1
  233. package/build/modern/useInfiniteQuery.js +1 -2
  234. package/build/modern/useInfiniteQuery.js.map +1 -1
  235. package/build/modern/useIsFetching.cjs +2 -3
  236. package/build/modern/useIsFetching.cjs.map +1 -1
  237. package/build/modern/useIsFetching.d.cts +1 -3
  238. package/build/modern/useIsFetching.d.cts.map +1 -1
  239. package/build/modern/useIsFetching.d.ts +1 -3
  240. package/build/modern/useIsFetching.d.ts.map +1 -1
  241. package/build/modern/useIsFetching.js +1 -2
  242. package/build/modern/useIsFetching.js.map +1 -1
  243. package/build/modern/useMutation.cjs +2 -3
  244. package/build/modern/useMutation.d.cts +0 -2
  245. package/build/modern/useMutation.d.cts.map +1 -1
  246. package/build/modern/useMutation.d.ts +0 -2
  247. package/build/modern/useMutation.d.ts.map +1 -1
  248. package/build/modern/useMutation.js +1 -2
  249. package/build/modern/useMutationState.cjs +2 -3
  250. package/build/modern/useMutationState.cjs.map +1 -1
  251. package/build/modern/useMutationState.d.cts +1 -3
  252. package/build/modern/useMutationState.d.cts.map +1 -1
  253. package/build/modern/useMutationState.d.ts +1 -3
  254. package/build/modern/useMutationState.d.ts.map +1 -1
  255. package/build/modern/useMutationState.js +1 -2
  256. package/build/modern/useMutationState.js.map +1 -1
  257. package/build/modern/usePrefetchInfiniteQuery.cjs +1 -2
  258. package/build/modern/usePrefetchInfiniteQuery.d.cts +0 -2
  259. package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
  260. package/build/modern/usePrefetchInfiniteQuery.d.ts +0 -2
  261. package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
  262. package/build/modern/usePrefetchInfiniteQuery.js +1 -2
  263. package/build/modern/usePrefetchQuery.cjs +1 -2
  264. package/build/modern/usePrefetchQuery.d.cts +0 -2
  265. package/build/modern/usePrefetchQuery.d.cts.map +1 -1
  266. package/build/modern/usePrefetchQuery.d.ts +0 -2
  267. package/build/modern/usePrefetchQuery.d.ts.map +1 -1
  268. package/build/modern/usePrefetchQuery.js +1 -2
  269. package/build/modern/useQueries.cjs +4 -5
  270. package/build/modern/useQueries.cjs.map +1 -1
  271. package/build/modern/useQueries.d.cts +0 -2
  272. package/build/modern/useQueries.d.cts.map +1 -1
  273. package/build/modern/useQueries.d.ts +0 -2
  274. package/build/modern/useQueries.d.ts.map +1 -1
  275. package/build/modern/useQueries.js +3 -4
  276. package/build/modern/useQueries.js.map +1 -1
  277. package/build/modern/useQuery.cjs +1 -2
  278. package/build/modern/useQuery.cjs.map +1 -1
  279. package/build/modern/useQuery.d.cts +5 -7
  280. package/build/modern/useQuery.d.cts.map +1 -1
  281. package/build/modern/useQuery.d.ts +5 -7
  282. package/build/modern/useQuery.d.ts.map +1 -1
  283. package/build/modern/useQuery.js +1 -2
  284. package/build/modern/useQuery.js.map +1 -1
  285. package/build/modern/useSuspenseInfiniteQuery.cjs +1 -2
  286. package/build/modern/useSuspenseInfiniteQuery.d.cts +0 -2
  287. package/build/modern/useSuspenseInfiniteQuery.d.cts.map +1 -1
  288. package/build/modern/useSuspenseInfiniteQuery.d.ts +0 -2
  289. package/build/modern/useSuspenseInfiniteQuery.d.ts.map +1 -1
  290. package/build/modern/useSuspenseInfiniteQuery.js +1 -2
  291. package/build/modern/useSuspenseQueries.cjs +1 -2
  292. package/build/modern/useSuspenseQueries.d.cts +0 -2
  293. package/build/modern/useSuspenseQueries.d.cts.map +1 -1
  294. package/build/modern/useSuspenseQueries.d.ts +0 -2
  295. package/build/modern/useSuspenseQueries.d.ts.map +1 -1
  296. package/build/modern/useSuspenseQueries.js +1 -2
  297. package/build/modern/useSuspenseQuery.cjs +1 -2
  298. package/build/modern/useSuspenseQuery.d.cts +0 -2
  299. package/build/modern/useSuspenseQuery.d.cts.map +1 -1
  300. package/build/modern/useSuspenseQuery.d.ts +0 -2
  301. package/build/modern/useSuspenseQuery.d.ts.map +1 -1
  302. package/build/modern/useSuspenseQuery.js +1 -2
  303. package/package.json +8 -8
  304. package/src/infiniteQueryOptions.ts +15 -14
  305. package/src/queryOptions.ts +16 -13
  306. package/src/useBaseQuery.ts +4 -4
  307. package/src/useInfiniteQuery.ts +2 -2
  308. package/src/useIsFetching.ts +1 -1
  309. package/src/useMutationState.ts +1 -1
  310. package/src/useQueries.ts +7 -7
  311. package/src/useQuery.ts +5 -5
@@ -1,9 +1,9 @@
1
1
  import { UseInfiniteQueryOptions } from "./types.js";
2
2
  import { DefaultError, InfiniteData, InitialDataFunction, NonUndefinedGuard, OmitKeyof, QueryKey, QueryKeyWithDataTag, SkipToken } from "@tanstack/query-core";
3
- //#region src/infiniteQueryOptions.d.ts
4
3
  /**
5
- * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data`
6
- * may be `undefined` while the query is `pending`.
4
+ * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is omitted, may be
5
+ * `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is
6
+ * `pending`.
7
7
  * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
8
8
  * @template TError - The type of errors your `queryFn` may throw.
9
9
  * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
@@ -22,9 +22,9 @@ export type UndefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultEr
22
22
  initialData?: undefined | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | InitialDataFunction<NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>>;
23
23
  };
24
24
  /**
25
- * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set and
26
- * `queryFn` is not `skipToken` — same as {@link UndefinedInitialDataInfiniteOptions}, but `queryFn` may not be
27
- * `skipToken`.
25
+ * The options accepted by the `infiniteQueryOptions` overload selected when `queryFn` is not `skipToken` and
26
+ * `initialData` is omitted, may be `undefined`, or is a function that may return `undefined` — same as
27
+ * {@link UndefinedInitialDataInfiniteOptions}, but `queryFn` may not be `skipToken`.
28
28
  * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
29
29
  * @template TError - The type of errors your `queryFn` may throw.
30
30
  * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
@@ -34,16 +34,17 @@ export type UndefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultEr
34
34
  */
35
35
  export type UnusedSkipTokenInfiniteOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = OmitKeyof<UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'queryFn'> & {
36
36
  /**
37
- * `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If
38
- * you don't intend to run the query yet, set `enabled: false` — omitting `queryFn` alone still triggers a
39
- * fetch that fails with "Missing queryFn" unless `enabled` is `false` or a default query function has been
40
- * defined. A default query function only supplies `queryFn`; it doesn't defer the fetch on its own.
37
+ * `skipToken` is not allowed as a value here — this overload is selected when `initialData` is omitted, may
38
+ * be `undefined`, or is a function that may return `undefined`. If you don't intend to run the query yet,
39
+ * set `enabled: false` — omitting `queryFn` alone still triggers a fetch that fails with "Missing queryFn"
40
+ * unless `enabled` is `false` or a default query function has been defined. A default query function only
41
+ * supplies `queryFn`; it doesn't defer the fetch on its own.
41
42
  */
42
43
  queryFn?: Exclude<UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>['queryFn'], SkipToken | undefined>;
43
44
  };
44
45
  /**
45
- * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is
46
- * never `undefined` (unless a `select` changes `TData` to include `undefined`).
46
+ * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is known to be
47
+ * defined — `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).
47
48
  * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
48
49
  * @template TError - The type of errors your `queryFn` may throw.
49
50
  * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
@@ -59,15 +60,15 @@ export type DefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultErro
59
60
  * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the
60
61
  * cache.
61
62
  */
62
- initialData: NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>) | undefined;
63
+ initialData: NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>);
63
64
  };
64
65
  /**
65
66
  * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.
66
67
  * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.
67
68
  * `options.queryKey` is required and is the query key to generate options for.
68
69
  *
69
- * This overload is selected when `initialData` is set.
70
- * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set.
70
+ * This overload is selected when `initialData` is known to be defined.
71
+ * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` known to be defined.
71
72
  * @returns The same options object, typed so that `queryKey` carries the inferred data type.
72
73
  * @remarks See {@link useInfiniteQuery} for examples that fetch further pages, from a button click or
73
74
  * automatically as the user scrolls.
@@ -175,5 +176,4 @@ export declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError
175
176
  * ```
176
177
  */
177
178
  export declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
178
- //#endregion
179
179
  //# sourceMappingURL=infiniteQueryOptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"infiniteQueryOptions.d.ts","names":[],"sources":["../../src/infiniteQueryOptions.ts"],"mappings":";;;;;;;;;;;;;YAsBY,oCACV,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,wBACE,wBACF,cACA,QACA,OACA,WACA;;;;;;;;EASA,0BAEI,kBAAkB,aAAa,cAAc,eAC7C,oBACE,kBAAkB,aAAa,cAAc;;;;;;;;;;;;;YAezC,+BACV,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,wBACE,UACF,wBAAwB,cAAc,QAAQ,OAAO,WAAW;;;;;;;EAShE,UAAU,QACR,wBACE,cACA,QACA,OACA,WACA,wBAEF;;;;;;;;;;;;YAcQ,kCACV,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,wBACE,wBACF,cACA,QACA,OACA,WACA;;;;;;;;EASA,aACI,kBAAkB,aAAa,cAAc,sBACtC,kBAAkB,aAAa,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA2C1C,qBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,kCACP,cACA,QACA,OACA,WACA,cAED,kCACD,cACA,QACA,OACA,WACA,cAEA,oBAAoB,WAAW,aAAa,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAsC7C,qBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,+BACP,cACA,QACA,OACA,WACA,cAED,+BACD,cACA,QACA,OACA,WACA,cAEA,oBAAoB,WAAW,aAAa,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAsC7C,qBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,oCACP,cACA,QACA,OACA,WACA,cAED,oCACD,cACA,QACA,OACA,WACA,cAEA,oBAAoB,WAAW,aAAa,eAAe"}
1
+ {"version":3,"file":"infiniteQueryOptions.d.ts","names":[],"sources":["../../src/infiniteQueryOptions.ts"],"mappings":";;;;;;;;;;;;;YAuBY,oCACV,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,wBACE,wBACF,cACA,QACA,OACA,WACA;;;;;;;;EASA,0BAEI,kBAAkB,aAAa,cAAc,eAC7C,oBACE,kBAAkB,aAAa,cAAc;;;;;;;;;;;;;YAezC,+BACV,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,wBACE,UACF,wBAAwB,cAAc,QAAQ,OAAO,WAAW;;;;;;;;EAUhE,UAAU,QACR,wBACE,cACA,QACA,OACA,WACA,wBAEF;;;;;;;;;;;;YAcQ,kCACV,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,wBACE,wBACF,cACA,QACA,OACA,WACA;;;;;;;;EASA,aACI,kBAAkB,aAAa,cAAc,sBACtC,kBAAkB,aAAa,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0C1C,qBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,kCACP,cACA,QACA,OACA,WACA,cAED,kCACD,cACA,QACA,OACA,WACA,cAEA,oBAAoB,WAAW,aAAa,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAsC7C,qBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,+BACP,cACA,QACA,OACA,WACA,cAED,+BACD,cACA,QACA,OACA,WACA,cAEA,oBAAoB,WAAW,aAAa,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAsC7C,qBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,oCACP,cACA,QACA,OACA,WACA,cAED,oCACD,cACA,QACA,OACA,WACA,cAEA,oBAAoB,WAAW,aAAa,eAAe"}
@@ -1,8 +1,7 @@
1
- //#region src/infiniteQueryOptions.ts
1
+ // src/infiniteQueryOptions.ts
2
2
  function infiniteQueryOptions(options) {
3
3
  return options;
4
4
  }
5
- //#endregion
6
5
  export { infiniteQueryOptions };
7
6
 
8
7
  //# sourceMappingURL=infiniteQueryOptions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"infiniteQueryOptions.js","names":[],"sources":["../../src/infiniteQueryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InfiniteData,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryKey,\n QueryKeyWithDataTag,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { UseInfiniteQueryOptions } from './types'\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data`\n * may be `undefined` while the query is `pending`.\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData?:\n | undefined\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | InitialDataFunction<\n NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n >\n}\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set and\n * `queryFn` is not `skipToken` — same as {@link UndefinedInitialDataInfiniteOptions}, but `queryFn` may not be\n * `skipToken`.\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = OmitKeyof<\n UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>,\n 'queryFn'\n> & {\n /**\n * `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If\n * you don't intend to run the query yet, set `enabled: false` — omitting `queryFn` alone still triggers a\n * fetch that fails with \"Missing queryFn\" unless `enabled` is `false` or a default query function has been\n * defined. A default query function only supplies `queryFn`; it doesn't defer the fetch on its own.\n */\n queryFn?: Exclude<\n UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >['queryFn'],\n SkipToken | undefined\n >\n}\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is\n * never `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n | undefined\n}\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages, from a button click or\n * automatically as the user scrolls.\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @example\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * function Projects() {\n * // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const { data, isError, error } = useInfiniteQuery(projectsOptions)\n *\n * return (\n * <div>\n * {isError ? <span>Error: {error.message}</span> : null}\n * <ul>\n * {data.pages.map((page) => page.projects.map((p) => <li key={p.id}>{p.name}</li>))}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n * @param options - The {@link UnusedSkipTokenInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages, from a button click or\n * automatically as the user scrolls.\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @example\n * A parameterized factory, so the same options object can be reused per `postId`:\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const commentsOptions = (postId: string) =>\n * infiniteQueryOptions({\n * queryKey: ['post', postId, 'comments'],\n * queryFn: ({ pageParam }) => fetchComments(postId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function Comments({ postId }: { postId: string }) {\n * const { data, isPending, isError, error } = useInfiniteQuery(commentsOptions(postId))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return (\n * <ul>\n * {data.pages.map((page) => page.comments.map((c) => <li key={c.id}>{c.text}</li>))}\n * </ul>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages (from a button click or\n * automatically as the user scrolls) and that use `skipToken` to disable the query until `postId` is set.\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @example\n * A parameterized factory, so the same options object can be reused per `postId`:\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const commentsOptions = (postId: string) =>\n * infiniteQueryOptions({\n * queryKey: ['post', postId, 'comments'],\n * queryFn: ({ pageParam }) => fetchComments(postId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function Comments({ postId }: { postId: string }) {\n * const { data, isPending, isError, error } = useInfiniteQuery(commentsOptions(postId))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return (\n * <ul>\n * {data.pages.map((page) => page.comments.map((c) => <li key={c.id}>{c.text}</li>))}\n * </ul>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n"],"mappings":";AAiTA,SAAgB,qBAAqB,SAAkB;CACrD,OAAO;AACT"}
1
+ {"version":3,"file":"infiniteQueryOptions.js","names":[],"sources":["../../src/infiniteQueryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InfiniteData,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryKey,\n QueryKeyWithDataTag,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { UseInfiniteQueryOptions } from './types'\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is omitted, may be\n * `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is\n * `pending`.\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData?:\n | undefined\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | InitialDataFunction<\n NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n >\n}\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `queryFn` is not `skipToken` and\n * `initialData` is omitted, may be `undefined`, or is a function that may return `undefined` — same as\n * {@link UndefinedInitialDataInfiniteOptions}, but `queryFn` may not be `skipToken`.\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = OmitKeyof<\n UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>,\n 'queryFn'\n> & {\n /**\n * `skipToken` is not allowed as a value here — this overload is selected when `initialData` is omitted, may\n * be `undefined`, or is a function that may return `undefined`. If you don't intend to run the query yet,\n * set `enabled: false` — omitting `queryFn` alone still triggers a fetch that fails with \"Missing queryFn\"\n * unless `enabled` is `false` or a default query function has been defined. A default query function only\n * supplies `queryFn`; it doesn't defer the fetch on its own.\n */\n queryFn?: Exclude<\n UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >['queryFn'],\n SkipToken | undefined\n >\n}\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is known to be\n * defined — `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n}\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * This overload is selected when `initialData` is known to be defined.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` known to be defined.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages, from a button click or\n * automatically as the user scrolls.\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @example\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * function Projects() {\n * // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const { data, isError, error } = useInfiniteQuery(projectsOptions)\n *\n * return (\n * <div>\n * {isError ? <span>Error: {error.message}</span> : null}\n * <ul>\n * {data.pages.map((page) => page.projects.map((p) => <li key={p.id}>{p.name}</li>))}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n * @param options - The {@link UnusedSkipTokenInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages, from a button click or\n * automatically as the user scrolls.\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @example\n * A parameterized factory, so the same options object can be reused per `postId`:\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const commentsOptions = (postId: string) =>\n * infiniteQueryOptions({\n * queryKey: ['post', postId, 'comments'],\n * queryFn: ({ pageParam }) => fetchComments(postId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function Comments({ postId }: { postId: string }) {\n * const { data, isPending, isError, error } = useInfiniteQuery(commentsOptions(postId))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return (\n * <ul>\n * {data.pages.map((page) => page.comments.map((c) => <li key={c.id}>{c.text}</li>))}\n * </ul>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages (from a button click or\n * automatically as the user scrolls) and that use `skipToken` to disable the query until `postId` is set.\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @example\n * A parameterized factory, so the same options object can be reused per `postId`:\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const commentsOptions = (postId: string) =>\n * infiniteQueryOptions({\n * queryKey: ['post', postId, 'comments'],\n * queryFn: ({ pageParam }) => fetchComments(postId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function Comments({ postId }: { postId: string }) {\n * const { data, isPending, isError, error } = useInfiniteQuery(commentsOptions(postId))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return (\n * <ul>\n * {data.pages.map((page) => page.comments.map((c) => <li key={c.id}>{c.text}</li>))}\n * </ul>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n"],"mappings":";AAkTA,SAAgB,qBAAqB,SAAkB;CACrD,OAAO;AACT"}
@@ -1,9 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/mutationOptions.ts
2
+ // src/mutationOptions.ts
3
3
  function mutationOptions(options) {
4
4
  return options;
5
5
  }
6
- //#endregion
7
6
  exports.mutationOptions = mutationOptions;
8
7
 
9
8
  //# sourceMappingURL=mutationOptions.cjs.map
@@ -1,6 +1,5 @@
1
1
  import { UseMutationOptions } from "./types.cjs";
2
2
  import { DefaultError, WithRequired } from "@tanstack/query-core";
3
- //#region src/mutationOptions.d.ts
4
3
  /**
5
4
  * You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. A
6
5
  * `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with
@@ -54,5 +53,4 @@ export declare function mutationOptions<TData = unknown, TError = DefaultError,
54
53
  * ```
55
54
  */
56
55
  export declare function mutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown>(options: Omit<UseMutationOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'>): Omit<UseMutationOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'>;
57
- //#endregion
58
56
  //# sourceMappingURL=mutationOptions.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mutationOptions.d.cts","names":[],"sources":["../../src/mutationOptions.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA8BgB,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,aACP,mBAAmB,OAAO,QAAQ,YAAY,mCAG/C,aACD,mBAAmB,OAAO,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;wBA2BhC,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,KACP,mBAAmB,OAAO,QAAQ,YAAY,mCAG/C,KACD,mBAAmB,OAAO,QAAQ,YAAY"}
1
+ {"version":3,"file":"mutationOptions.d.cts","names":[],"sources":["../../src/mutationOptions.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA8BgB,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,aACP,mBAAmB,OAAO,QAAQ,YAAY,mCAG/C,aACD,mBAAmB,OAAO,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;wBA2BhC,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,KACP,mBAAmB,OAAO,QAAQ,YAAY,mCAG/C,KACD,mBAAmB,OAAO,QAAQ,YAAY"}
@@ -1,6 +1,5 @@
1
1
  import { UseMutationOptions } from "./types.js";
2
2
  import { DefaultError, WithRequired } from "@tanstack/query-core";
3
- //#region src/mutationOptions.d.ts
4
3
  /**
5
4
  * You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. A
6
5
  * `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with
@@ -54,5 +53,4 @@ export declare function mutationOptions<TData = unknown, TError = DefaultError,
54
53
  * ```
55
54
  */
56
55
  export declare function mutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown>(options: Omit<UseMutationOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'>): Omit<UseMutationOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'>;
57
- //#endregion
58
56
  //# sourceMappingURL=mutationOptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mutationOptions.d.ts","names":[],"sources":["../../src/mutationOptions.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA8BgB,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,aACP,mBAAmB,OAAO,QAAQ,YAAY,mCAG/C,aACD,mBAAmB,OAAO,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;wBA2BhC,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,KACP,mBAAmB,OAAO,QAAQ,YAAY,mCAG/C,KACD,mBAAmB,OAAO,QAAQ,YAAY"}
1
+ {"version":3,"file":"mutationOptions.d.ts","names":[],"sources":["../../src/mutationOptions.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA8BgB,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,aACP,mBAAmB,OAAO,QAAQ,YAAY,mCAG/C,aACD,mBAAmB,OAAO,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;wBA2BhC,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,KACP,mBAAmB,OAAO,QAAQ,YAAY,mCAG/C,KACD,mBAAmB,OAAO,QAAQ,YAAY"}
@@ -1,8 +1,7 @@
1
- //#region src/mutationOptions.ts
1
+ // src/mutationOptions.ts
2
2
  function mutationOptions(options) {
3
3
  return options;
4
4
  }
5
- //#endregion
6
5
  export { mutationOptions };
7
6
 
8
7
  //# sourceMappingURL=mutationOptions.js.map
@@ -1,9 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/queryOptions.ts
2
+ // src/queryOptions.ts
3
3
  function queryOptions(options) {
4
4
  return options;
5
5
  }
6
- //#endregion
7
6
  exports.queryOptions = queryOptions;
8
7
 
9
8
  //# sourceMappingURL=queryOptions.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"queryOptions.cjs","names":[],"sources":["../../src/queryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryFunction,\n QueryKey,\n QueryKeyWithDataTag,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { UseQueryOptions } from './types'\n\n/**\n * The options accepted by the `queryOptions` overload selected when no `initialData` is set — `data` may be\n * `undefined` while the query is `pending`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UndefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = UseQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData?:\n | undefined\n | InitialDataFunction<NonUndefinedGuard<TQueryFnData>>\n | NonUndefinedGuard<TQueryFnData>\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when no `initialData` is set and `queryFn` is\n * not `skipToken` — same as {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UnusedSkipTokenOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'queryFn'\n> & {\n /**\n * `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If\n * you don't intend to run the query yet, set `enabled: false` — omitting `queryFn` alone still triggers a\n * fetch that fails with \"Missing queryFn\" unless `enabled` is `false` or a default query function has been\n * defined. A default query function only supplies `queryFn`; it doesn't defer the fetch on its own.\n */\n queryFn?: Exclude<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'],\n SkipToken | undefined\n >\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryFn'> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<TQueryFnData>\n | (() => NonUndefinedGuard<TQueryFnData>)\n /**\n * Optional here, but omitting it is only safe when no fetch will be attempted — for example with\n * `enabled: false`, or when a default query function has been defined. Otherwise, an enabled query with no\n * `queryFn` still tries to fetch and fails with a \"Missing queryFn\" error; `initialData` does not prevent this.\n */\n queryFn?: QueryFunction<TQueryFnData, TQueryKey>\n}\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless\n * a `select` changes `TData` to include `undefined`).\n * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postsOptions = queryOptions({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * function Posts() {\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery(postsOptions)\n *\n * return (\n * <div>\n * {isError ? <span>Error: {error.message}</span> : null}\n * <ul>\n * {data.map((post) => <li key={post.id}>{post.title}</li>)}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n * @param options - The {@link UnusedSkipTokenOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post({ id }: { id: string }) {\n * const { data, isPending, isError, error } = useQuery(postOptions(id))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data.title}</h1>\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks This is the only overload that accepts `queryFn: skipToken`, shown below.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post({ id }: { id: string }) {\n * const { data, isPending, isError, error } = useQuery(postOptions(id))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data.title}</h1>\n * }\n * ```\n * @example\n * A factory that disables the query, type safe, until `postId` is set:\n * ```tsx\n * import { queryOptions, skipToken, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (postId: number | undefined) =>\n * queryOptions({\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * })\n *\n * function Post({ postId }: { postId: number | undefined }) {\n * const { data, isLoading, isError, error } = useQuery(postOptions(postId))\n *\n * if (postId == null) return 'Select a post'\n * if (isLoading) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data?.title}</h1>\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\nexport function queryOptions(options: unknown) {\n return options\n}\n"],"mappings":";;AAuPA,SAAgB,aAAa,SAAkB;CAC7C,OAAO;AACT"}
1
+ {"version":3,"file":"queryOptions.cjs","names":[],"sources":["../../src/queryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryFunction,\n QueryKey,\n QueryKeyWithDataTag,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { UseQueryOptions } from './types'\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is omitted, may be\n * `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is\n * `pending`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UndefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = UseQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData?:\n | undefined\n | InitialDataFunction<NonUndefinedGuard<TQueryFnData>>\n | NonUndefinedGuard<TQueryFnData>\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when `queryFn` is not `skipToken` and\n * `initialData` is omitted, may be `undefined`, or is a function that may return `undefined` — same as\n * {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UnusedSkipTokenOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'queryFn'\n> & {\n /**\n * `skipToken` is not allowed as a value here — this overload is selected when `initialData` is omitted, may\n * be `undefined`, or is a function that may return `undefined`. If you don't intend to run the query yet,\n * set `enabled: false` — omitting `queryFn` alone still triggers a fetch that fails with \"Missing queryFn\"\n * unless `enabled` is `false` or a default query function has been defined. A default query function only\n * supplies `queryFn`; it doesn't defer the fetch on its own.\n */\n queryFn?: Exclude<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'],\n SkipToken | undefined\n >\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is known to be defined —\n * `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryFn'> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<TQueryFnData>\n | (() => NonUndefinedGuard<TQueryFnData>)\n /**\n * Optional here, but omitting it is only safe when no fetch will be attempted — for example with\n * `enabled: false`, or when a default query function has been defined. Otherwise, an enabled query with no\n * `queryFn` still tries to fetch and fails with a \"Missing queryFn\" error; `initialData` does not prevent this.\n */\n queryFn?: QueryFunction<TQueryFnData, TQueryKey>\n}\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n *\n * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` known to be defined.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postsOptions = queryOptions({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * function Posts() {\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery(postsOptions)\n *\n * return (\n * <div>\n * {isError ? <span>Error: {error.message}</span> : null}\n * <ul>\n * {data.map((post) => <li key={post.id}>{post.title}</li>)}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n * @param options - The {@link UnusedSkipTokenOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post({ id }: { id: string }) {\n * const { data, isPending, isError, error } = useQuery(postOptions(id))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data.title}</h1>\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks This is the only overload that accepts `queryFn: skipToken`, shown below.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post({ id }: { id: string }) {\n * const { data, isPending, isError, error } = useQuery(postOptions(id))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data.title}</h1>\n * }\n * ```\n * @example\n * A factory that disables the query, type safe, until `postId` is set:\n * ```tsx\n * import { queryOptions, skipToken, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (postId: number | undefined) =>\n * queryOptions({\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * })\n *\n * function Post({ postId }: { postId: number | undefined }) {\n * const { data, isLoading, isError, error } = useQuery(postOptions(postId))\n *\n * if (postId == null) return 'Select a post'\n * if (isLoading) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data?.title}</h1>\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\nexport function queryOptions(options: unknown) {\n return options\n}\n"],"mappings":";;AA0PA,SAAgB,aAAa,SAAkB;CAC7C,OAAO;AACT"}
@@ -1,9 +1,9 @@
1
1
  import { UseQueryOptions } from "./types.cjs";
2
2
  import { DefaultError, InitialDataFunction, NonUndefinedGuard, OmitKeyof, QueryFunction, QueryKey, QueryKeyWithDataTag, SkipToken } from "@tanstack/query-core";
3
- //#region src/queryOptions.d.ts
4
3
  /**
5
- * The options accepted by the `queryOptions` overload selected when no `initialData` is set — `data` may be
6
- * `undefined` while the query is `pending`.
4
+ * The options accepted by the `queryOptions` overload selected when `initialData` is omitted, may be
5
+ * `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is
6
+ * `pending`.
7
7
  * @template TQueryFnData - The type your `queryFn` resolves to.
8
8
  * @template TError - The type of errors your `queryFn` may throw.
9
9
  * @template TData - The type `data` ends up as after `select` runs.
@@ -20,8 +20,9 @@ export type UndefinedInitialDataOptions<TQueryFnData = unknown, TError = Default
20
20
  initialData?: undefined | InitialDataFunction<NonUndefinedGuard<TQueryFnData>> | NonUndefinedGuard<TQueryFnData>;
21
21
  };
22
22
  /**
23
- * The options accepted by the `queryOptions` overload selected when no `initialData` is set and `queryFn` is
24
- * not `skipToken` — same as {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.
23
+ * The options accepted by the `queryOptions` overload selected when `queryFn` is not `skipToken` and
24
+ * `initialData` is omitted, may be `undefined`, or is a function that may return `undefined` — same as
25
+ * {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.
25
26
  * @template TQueryFnData - The type your `queryFn` resolves to.
26
27
  * @template TError - The type of errors your `queryFn` may throw.
27
28
  * @template TData - The type `data` ends up as after `select` runs.
@@ -29,16 +30,17 @@ export type UndefinedInitialDataOptions<TQueryFnData = unknown, TError = Default
29
30
  */
30
31
  export type UnusedSkipTokenOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryFn'> & {
31
32
  /**
32
- * `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If
33
- * you don't intend to run the query yet, set `enabled: false` — omitting `queryFn` alone still triggers a
34
- * fetch that fails with "Missing queryFn" unless `enabled` is `false` or a default query function has been
35
- * defined. A default query function only supplies `queryFn`; it doesn't defer the fetch on its own.
33
+ * `skipToken` is not allowed as a value here — this overload is selected when `initialData` is omitted, may
34
+ * be `undefined`, or is a function that may return `undefined`. If you don't intend to run the query yet,
35
+ * set `enabled: false` — omitting `queryFn` alone still triggers a fetch that fails with "Missing queryFn"
36
+ * unless `enabled` is `false` or a default query function has been defined. A default query function only
37
+ * supplies `queryFn`; it doesn't defer the fetch on its own.
36
38
  */
37
39
  queryFn?: Exclude<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'], SkipToken | undefined>;
38
40
  };
39
41
  /**
40
- * The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never
41
- * `undefined` (unless a `select` changes `TData` to include `undefined`).
42
+ * The options accepted by the `queryOptions` overload selected when `initialData` is known to be defined —
43
+ * `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).
42
44
  * @template TQueryFnData - The type your `queryFn` resolves to.
43
45
  * @template TError - The type of errors your `queryFn` may throw.
44
46
  * @template TData - The type `data` ends up as after `select` runs.
@@ -65,9 +67,9 @@ export type DefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultEr
65
67
  * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and
66
68
  * is the query key to generate options for.
67
69
  *
68
- * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
69
- * a `select` changes `TData` to include `undefined`).
70
- * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.
70
+ * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never
71
+ * `undefined` (unless a `select` changes `TData` to include `undefined`).
72
+ * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` known to be defined.
71
73
  * @returns The same options object, typed so that `queryKey` carries the inferred data type.
72
74
  * @see {@link useQuery} to run a query with these options.
73
75
  * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.
@@ -180,5 +182,4 @@ export declare function queryOptions<TQueryFnData = unknown, TError = DefaultErr
180
182
  * ```
181
183
  */
182
184
  export declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> & QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>;
183
- //#endregion
184
185
  //# sourceMappingURL=queryOptions.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"queryOptions.d.cts","names":[],"sources":["../../src/queryOptions.ts"],"mappings":";;;;;;;;;;;YAoBY,4BACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;;EAQ/C,0BAEI,oBAAoB,kBAAkB,iBACtC,kBAAkB;;;;;;;;;;YAWZ,uBACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,UACF,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;EAS7C,UAAU,QACR,gBAAgB,cAAc,QAAQ,OAAO,uBAC7C;;;;;;;;;;YAYQ,0BACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,KAAK,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;;EAQpD,aACI,kBAAkB,uBACX,kBAAkB;;;;;;EAM7B,UAAU,cAAc,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwCxB,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,0BAA0B,cAAc,QAAQ,OAAO,aAC/D,0BAA0B,cAAc,QAAQ,OAAO,aACxD,oBAAoB,WAAW,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA+B/B,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,uBAAuB,cAAc,QAAQ,OAAO,aAC5D,uBAAuB,cAAc,QAAQ,OAAO,aACrD,oBAAoB,WAAW,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAqD/B,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,4BAA4B,cAAc,QAAQ,OAAO,aACjE,4BAA4B,cAAc,QAAQ,OAAO,aAC1D,oBAAoB,WAAW,cAAc"}
1
+ {"version":3,"file":"queryOptions.d.cts","names":[],"sources":["../../src/queryOptions.ts"],"mappings":";;;;;;;;;;;YAqBY,4BACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;;EAQ/C,0BAEI,oBAAoB,kBAAkB,iBACtC,kBAAkB;;;;;;;;;;;YAYZ,uBACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,UACF,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;;EAU7C,UAAU,QACR,gBAAgB,cAAc,QAAQ,OAAO,uBAC7C;;;;;;;;;;YAYQ,0BACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,KAAK,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;;EAQpD,aACI,kBAAkB,uBACX,kBAAkB;;;;;;EAM7B,UAAU,cAAc,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwCxB,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,0BAA0B,cAAc,QAAQ,OAAO,aAC/D,0BAA0B,cAAc,QAAQ,OAAO,aACxD,oBAAoB,WAAW,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA+B/B,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,uBAAuB,cAAc,QAAQ,OAAO,aAC5D,uBAAuB,cAAc,QAAQ,OAAO,aACrD,oBAAoB,WAAW,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAqD/B,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,4BAA4B,cAAc,QAAQ,OAAO,aACjE,4BAA4B,cAAc,QAAQ,OAAO,aAC1D,oBAAoB,WAAW,cAAc"}
@@ -1,9 +1,9 @@
1
1
  import { UseQueryOptions } from "./types.js";
2
2
  import { DefaultError, InitialDataFunction, NonUndefinedGuard, OmitKeyof, QueryFunction, QueryKey, QueryKeyWithDataTag, SkipToken } from "@tanstack/query-core";
3
- //#region src/queryOptions.d.ts
4
3
  /**
5
- * The options accepted by the `queryOptions` overload selected when no `initialData` is set — `data` may be
6
- * `undefined` while the query is `pending`.
4
+ * The options accepted by the `queryOptions` overload selected when `initialData` is omitted, may be
5
+ * `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is
6
+ * `pending`.
7
7
  * @template TQueryFnData - The type your `queryFn` resolves to.
8
8
  * @template TError - The type of errors your `queryFn` may throw.
9
9
  * @template TData - The type `data` ends up as after `select` runs.
@@ -20,8 +20,9 @@ export type UndefinedInitialDataOptions<TQueryFnData = unknown, TError = Default
20
20
  initialData?: undefined | InitialDataFunction<NonUndefinedGuard<TQueryFnData>> | NonUndefinedGuard<TQueryFnData>;
21
21
  };
22
22
  /**
23
- * The options accepted by the `queryOptions` overload selected when no `initialData` is set and `queryFn` is
24
- * not `skipToken` — same as {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.
23
+ * The options accepted by the `queryOptions` overload selected when `queryFn` is not `skipToken` and
24
+ * `initialData` is omitted, may be `undefined`, or is a function that may return `undefined` — same as
25
+ * {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.
25
26
  * @template TQueryFnData - The type your `queryFn` resolves to.
26
27
  * @template TError - The type of errors your `queryFn` may throw.
27
28
  * @template TData - The type `data` ends up as after `select` runs.
@@ -29,16 +30,17 @@ export type UndefinedInitialDataOptions<TQueryFnData = unknown, TError = Default
29
30
  */
30
31
  export type UnusedSkipTokenOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryFn'> & {
31
32
  /**
32
- * `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If
33
- * you don't intend to run the query yet, set `enabled: false` — omitting `queryFn` alone still triggers a
34
- * fetch that fails with "Missing queryFn" unless `enabled` is `false` or a default query function has been
35
- * defined. A default query function only supplies `queryFn`; it doesn't defer the fetch on its own.
33
+ * `skipToken` is not allowed as a value here — this overload is selected when `initialData` is omitted, may
34
+ * be `undefined`, or is a function that may return `undefined`. If you don't intend to run the query yet,
35
+ * set `enabled: false` — omitting `queryFn` alone still triggers a fetch that fails with "Missing queryFn"
36
+ * unless `enabled` is `false` or a default query function has been defined. A default query function only
37
+ * supplies `queryFn`; it doesn't defer the fetch on its own.
36
38
  */
37
39
  queryFn?: Exclude<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'], SkipToken | undefined>;
38
40
  };
39
41
  /**
40
- * The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never
41
- * `undefined` (unless a `select` changes `TData` to include `undefined`).
42
+ * The options accepted by the `queryOptions` overload selected when `initialData` is known to be defined —
43
+ * `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).
42
44
  * @template TQueryFnData - The type your `queryFn` resolves to.
43
45
  * @template TError - The type of errors your `queryFn` may throw.
44
46
  * @template TData - The type `data` ends up as after `select` runs.
@@ -65,9 +67,9 @@ export type DefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultEr
65
67
  * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and
66
68
  * is the query key to generate options for.
67
69
  *
68
- * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
69
- * a `select` changes `TData` to include `undefined`).
70
- * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.
70
+ * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never
71
+ * `undefined` (unless a `select` changes `TData` to include `undefined`).
72
+ * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` known to be defined.
71
73
  * @returns The same options object, typed so that `queryKey` carries the inferred data type.
72
74
  * @see {@link useQuery} to run a query with these options.
73
75
  * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.
@@ -180,5 +182,4 @@ export declare function queryOptions<TQueryFnData = unknown, TError = DefaultErr
180
182
  * ```
181
183
  */
182
184
  export declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> & QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>;
183
- //#endregion
184
185
  //# sourceMappingURL=queryOptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"queryOptions.d.ts","names":[],"sources":["../../src/queryOptions.ts"],"mappings":";;;;;;;;;;;YAoBY,4BACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;;EAQ/C,0BAEI,oBAAoB,kBAAkB,iBACtC,kBAAkB;;;;;;;;;;YAWZ,uBACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,UACF,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;EAS7C,UAAU,QACR,gBAAgB,cAAc,QAAQ,OAAO,uBAC7C;;;;;;;;;;YAYQ,0BACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,KAAK,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;;EAQpD,aACI,kBAAkB,uBACX,kBAAkB;;;;;;EAM7B,UAAU,cAAc,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwCxB,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,0BAA0B,cAAc,QAAQ,OAAO,aAC/D,0BAA0B,cAAc,QAAQ,OAAO,aACxD,oBAAoB,WAAW,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA+B/B,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,uBAAuB,cAAc,QAAQ,OAAO,aAC5D,uBAAuB,cAAc,QAAQ,OAAO,aACrD,oBAAoB,WAAW,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAqD/B,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,4BAA4B,cAAc,QAAQ,OAAO,aACjE,4BAA4B,cAAc,QAAQ,OAAO,aAC1D,oBAAoB,WAAW,cAAc"}
1
+ {"version":3,"file":"queryOptions.d.ts","names":[],"sources":["../../src/queryOptions.ts"],"mappings":";;;;;;;;;;;YAqBY,4BACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;;EAQ/C,0BAEI,oBAAoB,kBAAkB,iBACtC,kBAAkB;;;;;;;;;;;YAYZ,uBACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,UACF,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;;EAU7C,UAAU,QACR,gBAAgB,cAAc,QAAQ,OAAO,uBAC7C;;;;;;;;;;YAYQ,0BACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,KAAK,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;;EAQpD,aACI,kBAAkB,uBACX,kBAAkB;;;;;;EAM7B,UAAU,cAAc,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwCxB,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,0BAA0B,cAAc,QAAQ,OAAO,aAC/D,0BAA0B,cAAc,QAAQ,OAAO,aACxD,oBAAoB,WAAW,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA+B/B,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,uBAAuB,cAAc,QAAQ,OAAO,aAC5D,uBAAuB,cAAc,QAAQ,OAAO,aACrD,oBAAoB,WAAW,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAqD/B,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,4BAA4B,cAAc,QAAQ,OAAO,aACjE,4BAA4B,cAAc,QAAQ,OAAO,aAC1D,oBAAoB,WAAW,cAAc"}
@@ -1,8 +1,7 @@
1
- //#region src/queryOptions.ts
1
+ // src/queryOptions.ts
2
2
  function queryOptions(options) {
3
3
  return options;
4
4
  }
5
- //#endregion
6
5
  export { queryOptions };
7
6
 
8
7
  //# sourceMappingURL=queryOptions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"queryOptions.js","names":[],"sources":["../../src/queryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryFunction,\n QueryKey,\n QueryKeyWithDataTag,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { UseQueryOptions } from './types'\n\n/**\n * The options accepted by the `queryOptions` overload selected when no `initialData` is set — `data` may be\n * `undefined` while the query is `pending`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UndefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = UseQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData?:\n | undefined\n | InitialDataFunction<NonUndefinedGuard<TQueryFnData>>\n | NonUndefinedGuard<TQueryFnData>\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when no `initialData` is set and `queryFn` is\n * not `skipToken` — same as {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UnusedSkipTokenOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'queryFn'\n> & {\n /**\n * `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If\n * you don't intend to run the query yet, set `enabled: false` — omitting `queryFn` alone still triggers a\n * fetch that fails with \"Missing queryFn\" unless `enabled` is `false` or a default query function has been\n * defined. A default query function only supplies `queryFn`; it doesn't defer the fetch on its own.\n */\n queryFn?: Exclude<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'],\n SkipToken | undefined\n >\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryFn'> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<TQueryFnData>\n | (() => NonUndefinedGuard<TQueryFnData>)\n /**\n * Optional here, but omitting it is only safe when no fetch will be attempted — for example with\n * `enabled: false`, or when a default query function has been defined. Otherwise, an enabled query with no\n * `queryFn` still tries to fetch and fails with a \"Missing queryFn\" error; `initialData` does not prevent this.\n */\n queryFn?: QueryFunction<TQueryFnData, TQueryKey>\n}\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless\n * a `select` changes `TData` to include `undefined`).\n * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postsOptions = queryOptions({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * function Posts() {\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery(postsOptions)\n *\n * return (\n * <div>\n * {isError ? <span>Error: {error.message}</span> : null}\n * <ul>\n * {data.map((post) => <li key={post.id}>{post.title}</li>)}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n * @param options - The {@link UnusedSkipTokenOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post({ id }: { id: string }) {\n * const { data, isPending, isError, error } = useQuery(postOptions(id))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data.title}</h1>\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks This is the only overload that accepts `queryFn: skipToken`, shown below.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post({ id }: { id: string }) {\n * const { data, isPending, isError, error } = useQuery(postOptions(id))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data.title}</h1>\n * }\n * ```\n * @example\n * A factory that disables the query, type safe, until `postId` is set:\n * ```tsx\n * import { queryOptions, skipToken, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (postId: number | undefined) =>\n * queryOptions({\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * })\n *\n * function Post({ postId }: { postId: number | undefined }) {\n * const { data, isLoading, isError, error } = useQuery(postOptions(postId))\n *\n * if (postId == null) return 'Select a post'\n * if (isLoading) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data?.title}</h1>\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\nexport function queryOptions(options: unknown) {\n return options\n}\n"],"mappings":";AAuPA,SAAgB,aAAa,SAAkB;CAC7C,OAAO;AACT"}
1
+ {"version":3,"file":"queryOptions.js","names":[],"sources":["../../src/queryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryFunction,\n QueryKey,\n QueryKeyWithDataTag,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { UseQueryOptions } from './types'\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is omitted, may be\n * `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is\n * `pending`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UndefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = UseQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData?:\n | undefined\n | InitialDataFunction<NonUndefinedGuard<TQueryFnData>>\n | NonUndefinedGuard<TQueryFnData>\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when `queryFn` is not `skipToken` and\n * `initialData` is omitted, may be `undefined`, or is a function that may return `undefined` — same as\n * {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UnusedSkipTokenOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'queryFn'\n> & {\n /**\n * `skipToken` is not allowed as a value here — this overload is selected when `initialData` is omitted, may\n * be `undefined`, or is a function that may return `undefined`. If you don't intend to run the query yet,\n * set `enabled: false` — omitting `queryFn` alone still triggers a fetch that fails with \"Missing queryFn\"\n * unless `enabled` is `false` or a default query function has been defined. A default query function only\n * supplies `queryFn`; it doesn't defer the fetch on its own.\n */\n queryFn?: Exclude<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'],\n SkipToken | undefined\n >\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is known to be defined —\n * `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryFn'> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<TQueryFnData>\n | (() => NonUndefinedGuard<TQueryFnData>)\n /**\n * Optional here, but omitting it is only safe when no fetch will be attempted — for example with\n * `enabled: false`, or when a default query function has been defined. Otherwise, an enabled query with no\n * `queryFn` still tries to fetch and fails with a \"Missing queryFn\" error; `initialData` does not prevent this.\n */\n queryFn?: QueryFunction<TQueryFnData, TQueryKey>\n}\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n *\n * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` known to be defined.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postsOptions = queryOptions({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * function Posts() {\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery(postsOptions)\n *\n * return (\n * <div>\n * {isError ? <span>Error: {error.message}</span> : null}\n * <ul>\n * {data.map((post) => <li key={post.id}>{post.title}</li>)}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n * @param options - The {@link UnusedSkipTokenOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post({ id }: { id: string }) {\n * const { data, isPending, isError, error } = useQuery(postOptions(id))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data.title}</h1>\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks This is the only overload that accepts `queryFn: skipToken`, shown below.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post({ id }: { id: string }) {\n * const { data, isPending, isError, error } = useQuery(postOptions(id))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data.title}</h1>\n * }\n * ```\n * @example\n * A factory that disables the query, type safe, until `postId` is set:\n * ```tsx\n * import { queryOptions, skipToken, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (postId: number | undefined) =>\n * queryOptions({\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * })\n *\n * function Post({ postId }: { postId: number | undefined }) {\n * const { data, isLoading, isError, error } = useQuery(postOptions(postId))\n *\n * if (postId == null) return 'Select a post'\n * if (isLoading) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data?.title}</h1>\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\nexport function queryOptions(options: unknown) {\n return options\n}\n"],"mappings":";AA0PA,SAAgB,aAAa,SAAkB;CAC7C,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- //#region \0rolldown/runtime.js
1
+ // \0rolldown/runtime.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -19,7 +19,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
19
19
  value: mod,
20
20
  enumerable: true
21
21
  }) : target, mod));
22
- //#endregion
23
22
  Object.defineProperty(exports, "__toESM", {
24
23
  enumerable: true,
25
24
  get: function() {
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/suspense.ts
2
+ // src/suspense.ts
3
3
  /**
4
4
  * The default `throwOnError` of the suspense hooks: throws the error to the nearest error boundary
5
5
  * only if the query has no data to show.
@@ -41,7 +41,6 @@ const shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense &
41
41
  const fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
42
42
  errorResetBoundary.clearReset();
43
43
  });
44
- //#endregion
45
44
  exports.defaultThrowOnError = defaultThrowOnError;
46
45
  exports.ensureSuspenseTimers = ensureSuspenseTimers;
47
46
  exports.fetchOptimistic = fetchOptimistic;
@@ -1,6 +1,5 @@
1
1
  import { QueryErrorResetBoundaryValue } from "./QueryErrorResetBoundary.cjs";
2
2
  import { DefaultError, DefaultedQueryObserverOptions, Query, QueryKey, QueryObserver, QueryObserverResult } from "@tanstack/query-core";
3
- //#region src/suspense.d.ts
4
3
  /**
5
4
  * The default `throwOnError` of the suspense hooks: throws the error to the nearest error boundary
6
5
  * only if the query has no data to show.
@@ -32,5 +31,4 @@ export declare const shouldSuspend: (defaultedOptions: DefaultedQueryObserverOpt
32
31
  * @returns A promise that resolves once the fetch settles. It never rejects.
33
32
  */
34
33
  export declare const fetchOptimistic: <TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey>(defaultedOptions: DefaultedQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, observer: QueryObserver<TQueryFnData, TError, TData, TQueryData, TQueryKey>, errorResetBoundary: QueryErrorResetBoundaryValue) => Promise<void | QueryObserverResult<TData, TError>>;
35
- //#endregion
36
34
  //# sourceMappingURL=suspense.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"suspense.d.cts","names":[],"sources":["../../src/suspense.ts"],"mappings":";;;;;;;;;;qBAiBa,sBACX,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,QAAQ,QACR,OAAO,MAAM,cAAc,QAAQ,OAAO;;;;;;;qBAS/B,uBACX,kBAAkB;;;;;;;qBAiCP,gBACX,kBACI,oEAEJ,QAAQ;;;;;;;;;qBAWG,kBACX,cACA,QACA,OACA,YACA,kBAAkB,UAElB,kBAAkB,8BAChB,cACA,QACA,OACA,YACA,YAEF,UAAU,cAAc,cAAc,QAAQ,OAAO,YAAY,YACjE,oBAAoB,iCAA4B,eAAA,oBAAA,OAAA"}
1
+ {"version":3,"file":"suspense.d.cts","names":[],"sources":["../../src/suspense.ts"],"mappings":";;;;;;;;;qBAiBa,sBACX,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,QAAQ,QACR,OAAO,MAAM,cAAc,QAAQ,OAAO;;;;;;;qBAS/B,uBACX,kBAAkB;;;;;;;qBAiCP,gBACX,kBACI,oEAEJ,QAAQ;;;;;;;;;qBAWG,kBACX,cACA,QACA,OACA,YACA,kBAAkB,UAElB,kBAAkB,8BAChB,cACA,QACA,OACA,YACA,YAEF,UAAU,cAAc,cAAc,QAAQ,OAAO,YAAY,YACjE,oBAAoB,iCAA4B,eAAA,oBAAA,OAAA"}
@@ -1,6 +1,5 @@
1
1
  import { QueryErrorResetBoundaryValue } from "./QueryErrorResetBoundary.js";
2
2
  import { DefaultError, DefaultedQueryObserverOptions, Query, QueryKey, QueryObserver, QueryObserverResult } from "@tanstack/query-core";
3
- //#region src/suspense.d.ts
4
3
  /**
5
4
  * The default `throwOnError` of the suspense hooks: throws the error to the nearest error boundary
6
5
  * only if the query has no data to show.
@@ -32,5 +31,4 @@ export declare const shouldSuspend: (defaultedOptions: DefaultedQueryObserverOpt
32
31
  * @returns A promise that resolves once the fetch settles. It never rejects.
33
32
  */
34
33
  export declare const fetchOptimistic: <TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey>(defaultedOptions: DefaultedQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, observer: QueryObserver<TQueryFnData, TError, TData, TQueryData, TQueryKey>, errorResetBoundary: QueryErrorResetBoundaryValue) => Promise<void | QueryObserverResult<TData, TError>>;
35
- //#endregion
36
34
  //# sourceMappingURL=suspense.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"suspense.d.ts","names":[],"sources":["../../src/suspense.ts"],"mappings":";;;;;;;;;;qBAiBa,sBACX,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,QAAQ,QACR,OAAO,MAAM,cAAc,QAAQ,OAAO;;;;;;;qBAS/B,uBACX,kBAAkB;;;;;;;qBAiCP,gBACX,kBACI,oEAEJ,QAAQ;;;;;;;;;qBAWG,kBACX,cACA,QACA,OACA,YACA,kBAAkB,UAElB,kBAAkB,8BAChB,cACA,QACA,OACA,YACA,YAEF,UAAU,cAAc,cAAc,QAAQ,OAAO,YAAY,YACjE,oBAAoB,iCAA4B,eAAA,oBAAA,OAAA"}
1
+ {"version":3,"file":"suspense.d.ts","names":[],"sources":["../../src/suspense.ts"],"mappings":";;;;;;;;;qBAiBa,sBACX,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,QAAQ,QACR,OAAO,MAAM,cAAc,QAAQ,OAAO;;;;;;;qBAS/B,uBACX,kBAAkB;;;;;;;qBAiCP,gBACX,kBACI,oEAEJ,QAAQ;;;;;;;;;qBAWG,kBACX,cACA,QACA,OACA,YACA,kBAAkB,UAElB,kBAAkB,8BAChB,cACA,QACA,OACA,YACA,YAEF,UAAU,cAAc,cAAc,QAAQ,OAAO,YAAY,YACjE,oBAAoB,iCAA4B,eAAA,oBAAA,OAAA"}