@tanstack/react-query 5.102.8 → 5.103.0

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 (298) hide show
  1. package/build/legacy/HydrationBoundary.cjs +44 -1
  2. package/build/legacy/HydrationBoundary.cjs.map +1 -1
  3. package/build/legacy/HydrationBoundary.d.cts +61 -0
  4. package/build/legacy/HydrationBoundary.d.cts.map +1 -1
  5. package/build/legacy/HydrationBoundary.d.ts +61 -0
  6. package/build/legacy/HydrationBoundary.d.ts.map +1 -1
  7. package/build/legacy/HydrationBoundary.js +44 -1
  8. package/build/legacy/HydrationBoundary.js.map +1 -1
  9. package/build/legacy/IsRestoringProvider.cjs +11 -0
  10. package/build/legacy/IsRestoringProvider.cjs.map +1 -1
  11. package/build/legacy/IsRestoringProvider.d.cts +11 -0
  12. package/build/legacy/IsRestoringProvider.d.cts.map +1 -1
  13. package/build/legacy/IsRestoringProvider.d.ts +11 -0
  14. package/build/legacy/IsRestoringProvider.d.ts.map +1 -1
  15. package/build/legacy/IsRestoringProvider.js +11 -0
  16. package/build/legacy/IsRestoringProvider.js.map +1 -1
  17. package/build/legacy/QueryClientProvider.cjs +30 -0
  18. package/build/legacy/QueryClientProvider.cjs.map +1 -1
  19. package/build/legacy/QueryClientProvider.d.cts +41 -0
  20. package/build/legacy/QueryClientProvider.d.cts.map +1 -1
  21. package/build/legacy/QueryClientProvider.d.ts +41 -0
  22. package/build/legacy/QueryClientProvider.d.ts.map +1 -1
  23. package/build/legacy/QueryClientProvider.js +30 -0
  24. package/build/legacy/QueryClientProvider.js.map +1 -1
  25. package/build/legacy/QueryErrorResetBoundary.cjs +76 -0
  26. package/build/legacy/QueryErrorResetBoundary.cjs.map +1 -1
  27. package/build/legacy/QueryErrorResetBoundary.d.cts +77 -0
  28. package/build/legacy/QueryErrorResetBoundary.d.cts.map +1 -1
  29. package/build/legacy/QueryErrorResetBoundary.d.ts +77 -0
  30. package/build/legacy/QueryErrorResetBoundary.d.ts.map +1 -1
  31. package/build/legacy/QueryErrorResetBoundary.js +76 -0
  32. package/build/legacy/QueryErrorResetBoundary.js.map +1 -1
  33. package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
  34. package/build/legacy/infiniteQueryOptions.d.cts +173 -0
  35. package/build/legacy/infiniteQueryOptions.d.cts.map +1 -1
  36. package/build/legacy/infiniteQueryOptions.d.ts +173 -0
  37. package/build/legacy/infiniteQueryOptions.d.ts.map +1 -1
  38. package/build/legacy/infiniteQueryOptions.js.map +1 -1
  39. package/build/legacy/mutationOptions.cjs.map +1 -1
  40. package/build/legacy/mutationOptions.d.cts +55 -0
  41. package/build/legacy/mutationOptions.d.cts.map +1 -1
  42. package/build/legacy/mutationOptions.d.ts +55 -0
  43. package/build/legacy/mutationOptions.d.ts.map +1 -1
  44. package/build/legacy/mutationOptions.js.map +1 -1
  45. package/build/legacy/queryOptions.cjs.map +1 -1
  46. package/build/legacy/queryOptions.d.cts +175 -0
  47. package/build/legacy/queryOptions.d.cts.map +1 -1
  48. package/build/legacy/queryOptions.d.ts +175 -0
  49. package/build/legacy/queryOptions.d.ts.map +1 -1
  50. package/build/legacy/queryOptions.js.map +1 -1
  51. package/build/legacy/types.cjs.map +1 -1
  52. package/build/legacy/types.d.cts +228 -2
  53. package/build/legacy/types.d.cts.map +1 -1
  54. package/build/legacy/types.d.ts +228 -2
  55. package/build/legacy/types.d.ts.map +1 -1
  56. package/build/legacy/types.js.map +1 -1
  57. package/build/legacy/useInfiniteQuery.cjs.map +1 -1
  58. package/build/legacy/useInfiniteQuery.d.cts +292 -0
  59. package/build/legacy/useInfiniteQuery.d.cts.map +1 -1
  60. package/build/legacy/useInfiniteQuery.d.ts +292 -0
  61. package/build/legacy/useInfiniteQuery.d.ts.map +1 -1
  62. package/build/legacy/useInfiniteQuery.js.map +1 -1
  63. package/build/legacy/useIsFetching.cjs +36 -0
  64. package/build/legacy/useIsFetching.cjs.map +1 -1
  65. package/build/legacy/useIsFetching.d.cts +36 -0
  66. package/build/legacy/useIsFetching.d.cts.map +1 -1
  67. package/build/legacy/useIsFetching.d.ts +36 -0
  68. package/build/legacy/useIsFetching.d.ts.map +1 -1
  69. package/build/legacy/useIsFetching.js +36 -0
  70. package/build/legacy/useIsFetching.js.map +1 -1
  71. package/build/legacy/useMutation.cjs +172 -0
  72. package/build/legacy/useMutation.cjs.map +1 -1
  73. package/build/legacy/useMutation.d.cts +172 -0
  74. package/build/legacy/useMutation.d.cts.map +1 -1
  75. package/build/legacy/useMutation.d.ts +172 -0
  76. package/build/legacy/useMutation.d.ts.map +1 -1
  77. package/build/legacy/useMutation.js +172 -0
  78. package/build/legacy/useMutation.js.map +1 -1
  79. package/build/legacy/useMutationState.cjs +94 -0
  80. package/build/legacy/useMutationState.cjs.map +1 -1
  81. package/build/legacy/useMutationState.d.cts +94 -0
  82. package/build/legacy/useMutationState.d.cts.map +1 -1
  83. package/build/legacy/useMutationState.d.ts +94 -0
  84. package/build/legacy/useMutationState.d.ts.map +1 -1
  85. package/build/legacy/useMutationState.js +94 -0
  86. package/build/legacy/useMutationState.js.map +1 -1
  87. package/build/legacy/usePrefetchInfiniteQuery.cjs +44 -0
  88. package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
  89. package/build/legacy/usePrefetchInfiniteQuery.d.cts +44 -0
  90. package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
  91. package/build/legacy/usePrefetchInfiniteQuery.d.ts +44 -0
  92. package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
  93. package/build/legacy/usePrefetchInfiniteQuery.js +44 -0
  94. package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
  95. package/build/legacy/usePrefetchQuery.cjs +35 -0
  96. package/build/legacy/usePrefetchQuery.cjs.map +1 -1
  97. package/build/legacy/usePrefetchQuery.d.cts +35 -0
  98. package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
  99. package/build/legacy/usePrefetchQuery.d.ts +35 -0
  100. package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
  101. package/build/legacy/usePrefetchQuery.js +35 -0
  102. package/build/legacy/usePrefetchQuery.js.map +1 -1
  103. package/build/legacy/useQueries.cjs +130 -0
  104. package/build/legacy/useQueries.cjs.map +1 -1
  105. package/build/legacy/useQueries.d.cts +165 -2
  106. package/build/legacy/useQueries.d.cts.map +1 -1
  107. package/build/legacy/useQueries.d.ts +165 -2
  108. package/build/legacy/useQueries.d.ts.map +1 -1
  109. package/build/legacy/useQueries.js +130 -0
  110. package/build/legacy/useQueries.js.map +1 -1
  111. package/build/legacy/useQuery.cjs.map +1 -1
  112. package/build/legacy/useQuery.d.cts +246 -0
  113. package/build/legacy/useQuery.d.cts.map +1 -1
  114. package/build/legacy/useQuery.d.ts +246 -0
  115. package/build/legacy/useQuery.d.ts.map +1 -1
  116. package/build/legacy/useQuery.js.map +1 -1
  117. package/build/legacy/useSuspenseInfiniteQuery.cjs +86 -0
  118. package/build/legacy/useSuspenseInfiniteQuery.cjs.map +1 -1
  119. package/build/legacy/useSuspenseInfiniteQuery.d.cts +86 -0
  120. package/build/legacy/useSuspenseInfiniteQuery.d.cts.map +1 -1
  121. package/build/legacy/useSuspenseInfiniteQuery.d.ts +86 -0
  122. package/build/legacy/useSuspenseInfiniteQuery.d.ts.map +1 -1
  123. package/build/legacy/useSuspenseInfiniteQuery.js +86 -0
  124. package/build/legacy/useSuspenseInfiniteQuery.js.map +1 -1
  125. package/build/legacy/useSuspenseQueries.cjs.map +1 -1
  126. package/build/legacy/useSuspenseQueries.d.cts +320 -2
  127. package/build/legacy/useSuspenseQueries.d.cts.map +1 -1
  128. package/build/legacy/useSuspenseQueries.d.ts +320 -2
  129. package/build/legacy/useSuspenseQueries.d.ts.map +1 -1
  130. package/build/legacy/useSuspenseQueries.js.map +1 -1
  131. package/build/legacy/useSuspenseQuery.cjs +67 -0
  132. package/build/legacy/useSuspenseQuery.cjs.map +1 -1
  133. package/build/legacy/useSuspenseQuery.d.cts +67 -0
  134. package/build/legacy/useSuspenseQuery.d.cts.map +1 -1
  135. package/build/legacy/useSuspenseQuery.d.ts +67 -0
  136. package/build/legacy/useSuspenseQuery.d.ts.map +1 -1
  137. package/build/legacy/useSuspenseQuery.js +67 -0
  138. package/build/legacy/useSuspenseQuery.js.map +1 -1
  139. package/build/modern/HydrationBoundary.cjs +44 -1
  140. package/build/modern/HydrationBoundary.cjs.map +1 -1
  141. package/build/modern/HydrationBoundary.d.cts +61 -0
  142. package/build/modern/HydrationBoundary.d.cts.map +1 -1
  143. package/build/modern/HydrationBoundary.d.ts +61 -0
  144. package/build/modern/HydrationBoundary.d.ts.map +1 -1
  145. package/build/modern/HydrationBoundary.js +44 -1
  146. package/build/modern/HydrationBoundary.js.map +1 -1
  147. package/build/modern/IsRestoringProvider.cjs +11 -0
  148. package/build/modern/IsRestoringProvider.cjs.map +1 -1
  149. package/build/modern/IsRestoringProvider.d.cts +11 -0
  150. package/build/modern/IsRestoringProvider.d.cts.map +1 -1
  151. package/build/modern/IsRestoringProvider.d.ts +11 -0
  152. package/build/modern/IsRestoringProvider.d.ts.map +1 -1
  153. package/build/modern/IsRestoringProvider.js +11 -0
  154. package/build/modern/IsRestoringProvider.js.map +1 -1
  155. package/build/modern/QueryClientProvider.cjs +30 -0
  156. package/build/modern/QueryClientProvider.cjs.map +1 -1
  157. package/build/modern/QueryClientProvider.d.cts +41 -0
  158. package/build/modern/QueryClientProvider.d.cts.map +1 -1
  159. package/build/modern/QueryClientProvider.d.ts +41 -0
  160. package/build/modern/QueryClientProvider.d.ts.map +1 -1
  161. package/build/modern/QueryClientProvider.js +30 -0
  162. package/build/modern/QueryClientProvider.js.map +1 -1
  163. package/build/modern/QueryErrorResetBoundary.cjs +76 -0
  164. package/build/modern/QueryErrorResetBoundary.cjs.map +1 -1
  165. package/build/modern/QueryErrorResetBoundary.d.cts +77 -0
  166. package/build/modern/QueryErrorResetBoundary.d.cts.map +1 -1
  167. package/build/modern/QueryErrorResetBoundary.d.ts +77 -0
  168. package/build/modern/QueryErrorResetBoundary.d.ts.map +1 -1
  169. package/build/modern/QueryErrorResetBoundary.js +76 -0
  170. package/build/modern/QueryErrorResetBoundary.js.map +1 -1
  171. package/build/modern/infiniteQueryOptions.cjs.map +1 -1
  172. package/build/modern/infiniteQueryOptions.d.cts +173 -0
  173. package/build/modern/infiniteQueryOptions.d.cts.map +1 -1
  174. package/build/modern/infiniteQueryOptions.d.ts +173 -0
  175. package/build/modern/infiniteQueryOptions.d.ts.map +1 -1
  176. package/build/modern/infiniteQueryOptions.js.map +1 -1
  177. package/build/modern/mutationOptions.cjs.map +1 -1
  178. package/build/modern/mutationOptions.d.cts +55 -0
  179. package/build/modern/mutationOptions.d.cts.map +1 -1
  180. package/build/modern/mutationOptions.d.ts +55 -0
  181. package/build/modern/mutationOptions.d.ts.map +1 -1
  182. package/build/modern/mutationOptions.js.map +1 -1
  183. package/build/modern/queryOptions.cjs.map +1 -1
  184. package/build/modern/queryOptions.d.cts +175 -0
  185. package/build/modern/queryOptions.d.cts.map +1 -1
  186. package/build/modern/queryOptions.d.ts +175 -0
  187. package/build/modern/queryOptions.d.ts.map +1 -1
  188. package/build/modern/queryOptions.js.map +1 -1
  189. package/build/modern/types.cjs.map +1 -1
  190. package/build/modern/types.d.cts +228 -2
  191. package/build/modern/types.d.cts.map +1 -1
  192. package/build/modern/types.d.ts +228 -2
  193. package/build/modern/types.d.ts.map +1 -1
  194. package/build/modern/types.js.map +1 -1
  195. package/build/modern/useInfiniteQuery.cjs.map +1 -1
  196. package/build/modern/useInfiniteQuery.d.cts +292 -0
  197. package/build/modern/useInfiniteQuery.d.cts.map +1 -1
  198. package/build/modern/useInfiniteQuery.d.ts +292 -0
  199. package/build/modern/useInfiniteQuery.d.ts.map +1 -1
  200. package/build/modern/useInfiniteQuery.js.map +1 -1
  201. package/build/modern/useIsFetching.cjs +36 -0
  202. package/build/modern/useIsFetching.cjs.map +1 -1
  203. package/build/modern/useIsFetching.d.cts +36 -0
  204. package/build/modern/useIsFetching.d.cts.map +1 -1
  205. package/build/modern/useIsFetching.d.ts +36 -0
  206. package/build/modern/useIsFetching.d.ts.map +1 -1
  207. package/build/modern/useIsFetching.js +36 -0
  208. package/build/modern/useIsFetching.js.map +1 -1
  209. package/build/modern/useMutation.cjs +172 -0
  210. package/build/modern/useMutation.cjs.map +1 -1
  211. package/build/modern/useMutation.d.cts +172 -0
  212. package/build/modern/useMutation.d.cts.map +1 -1
  213. package/build/modern/useMutation.d.ts +172 -0
  214. package/build/modern/useMutation.d.ts.map +1 -1
  215. package/build/modern/useMutation.js +172 -0
  216. package/build/modern/useMutation.js.map +1 -1
  217. package/build/modern/useMutationState.cjs +94 -0
  218. package/build/modern/useMutationState.cjs.map +1 -1
  219. package/build/modern/useMutationState.d.cts +94 -0
  220. package/build/modern/useMutationState.d.cts.map +1 -1
  221. package/build/modern/useMutationState.d.ts +94 -0
  222. package/build/modern/useMutationState.d.ts.map +1 -1
  223. package/build/modern/useMutationState.js +94 -0
  224. package/build/modern/useMutationState.js.map +1 -1
  225. package/build/modern/usePrefetchInfiniteQuery.cjs +44 -0
  226. package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
  227. package/build/modern/usePrefetchInfiniteQuery.d.cts +44 -0
  228. package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
  229. package/build/modern/usePrefetchInfiniteQuery.d.ts +44 -0
  230. package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
  231. package/build/modern/usePrefetchInfiniteQuery.js +44 -0
  232. package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
  233. package/build/modern/usePrefetchQuery.cjs +35 -0
  234. package/build/modern/usePrefetchQuery.cjs.map +1 -1
  235. package/build/modern/usePrefetchQuery.d.cts +35 -0
  236. package/build/modern/usePrefetchQuery.d.cts.map +1 -1
  237. package/build/modern/usePrefetchQuery.d.ts +35 -0
  238. package/build/modern/usePrefetchQuery.d.ts.map +1 -1
  239. package/build/modern/usePrefetchQuery.js +35 -0
  240. package/build/modern/usePrefetchQuery.js.map +1 -1
  241. package/build/modern/useQueries.cjs +130 -0
  242. package/build/modern/useQueries.cjs.map +1 -1
  243. package/build/modern/useQueries.d.cts +165 -2
  244. package/build/modern/useQueries.d.cts.map +1 -1
  245. package/build/modern/useQueries.d.ts +165 -2
  246. package/build/modern/useQueries.d.ts.map +1 -1
  247. package/build/modern/useQueries.js +130 -0
  248. package/build/modern/useQueries.js.map +1 -1
  249. package/build/modern/useQuery.cjs.map +1 -1
  250. package/build/modern/useQuery.d.cts +246 -0
  251. package/build/modern/useQuery.d.cts.map +1 -1
  252. package/build/modern/useQuery.d.ts +246 -0
  253. package/build/modern/useQuery.d.ts.map +1 -1
  254. package/build/modern/useQuery.js.map +1 -1
  255. package/build/modern/useSuspenseInfiniteQuery.cjs +86 -0
  256. package/build/modern/useSuspenseInfiniteQuery.cjs.map +1 -1
  257. package/build/modern/useSuspenseInfiniteQuery.d.cts +86 -0
  258. package/build/modern/useSuspenseInfiniteQuery.d.cts.map +1 -1
  259. package/build/modern/useSuspenseInfiniteQuery.d.ts +86 -0
  260. package/build/modern/useSuspenseInfiniteQuery.d.ts.map +1 -1
  261. package/build/modern/useSuspenseInfiniteQuery.js +86 -0
  262. package/build/modern/useSuspenseInfiniteQuery.js.map +1 -1
  263. package/build/modern/useSuspenseQueries.cjs.map +1 -1
  264. package/build/modern/useSuspenseQueries.d.cts +320 -2
  265. package/build/modern/useSuspenseQueries.d.cts.map +1 -1
  266. package/build/modern/useSuspenseQueries.d.ts +320 -2
  267. package/build/modern/useSuspenseQueries.d.ts.map +1 -1
  268. package/build/modern/useSuspenseQueries.js.map +1 -1
  269. package/build/modern/useSuspenseQuery.cjs +67 -0
  270. package/build/modern/useSuspenseQuery.cjs.map +1 -1
  271. package/build/modern/useSuspenseQuery.d.cts +67 -0
  272. package/build/modern/useSuspenseQuery.d.cts.map +1 -1
  273. package/build/modern/useSuspenseQuery.d.ts +67 -0
  274. package/build/modern/useSuspenseQuery.d.ts.map +1 -1
  275. package/build/modern/useSuspenseQuery.js +67 -0
  276. package/build/modern/useSuspenseQuery.js.map +1 -1
  277. package/build/query-codemods/eslint.config.js +7 -0
  278. package/build/query-codemods/root.eslint.config.js +45 -0
  279. package/package.json +11 -11
  280. package/src/HydrationBoundary.tsx +61 -1
  281. package/src/IsRestoringProvider.ts +12 -0
  282. package/src/QueryClientProvider.tsx +41 -0
  283. package/src/QueryErrorResetBoundary.tsx +89 -0
  284. package/src/infiniteQueryOptions.ts +173 -0
  285. package/src/mutationOptions.ts +55 -0
  286. package/src/queryOptions.ts +175 -0
  287. package/src/types.ts +228 -2
  288. package/src/useInfiniteQuery.ts +292 -0
  289. package/src/useIsFetching.ts +36 -0
  290. package/src/useMutation.ts +172 -0
  291. package/src/useMutationState.ts +94 -0
  292. package/src/usePrefetchInfiniteQuery.tsx +44 -0
  293. package/src/usePrefetchQuery.tsx +35 -0
  294. package/src/useQueries.ts +165 -2
  295. package/src/useQuery.ts +246 -0
  296. package/src/useSuspenseInfiniteQuery.ts +86 -0
  297. package/src/useSuspenseQueries.ts +320 -2
  298. package/src/useSuspenseQuery.ts +67 -0
package/src/types.ts CHANGED
@@ -21,6 +21,10 @@ import type {
21
21
  SkipToken,
22
22
  } from '@tanstack/query-core'
23
23
 
24
+ /**
25
+ * {@link UseBaseQueryOptions} with all type parameters set to `any`, useful when the specific types aren't
26
+ * relevant, e.g. when accepting options for any query in a helper function.
27
+ */
24
28
  export type AnyUseBaseQueryOptions = UseBaseQueryOptions<
25
29
  any,
26
30
  any,
@@ -28,6 +32,18 @@ export type AnyUseBaseQueryOptions = UseBaseQueryOptions<
28
32
  any,
29
33
  any
30
34
  >
35
+ /**
36
+ * The options shared by `useQuery` and `useSuspenseQuery`. Extends {@link QueryObserverOptions} from
37
+ * `@tanstack/query-core` with the `react-query`-specific `subscribed` option.
38
+ *
39
+ * @template TQueryFnData - The type your `queryFn` resolves to.
40
+ * @template TError - The type of errors your `queryFn` may throw.
41
+ * @template TData - The type `data` ends up as after `select` runs. Defaults to `TQueryFnData` when no
42
+ * `select` is used.
43
+ * @template TQueryData - The type of the data actually held in the query cache — the input to `select` and
44
+ * `placeholderData`. Defaults to, and is usually the same as, `TQueryFnData`.
45
+ * @template TQueryKey - The type of your `queryKey`.
46
+ */
31
47
  export interface UseBaseQueryOptions<
32
48
  TQueryFnData = unknown,
33
49
  TError = DefaultError,
@@ -43,11 +59,24 @@ export interface UseBaseQueryOptions<
43
59
  > {
44
60
  /**
45
61
  * Set this to `false` to unsubscribe this observer from updates to the query cache.
46
- * Defaults to `true`.
62
+ *
63
+ * @defaultValue true
47
64
  */
48
65
  subscribed?: boolean
49
66
  }
50
67
 
68
+ /**
69
+ * The options accepted by `usePrefetchQuery` — everything you can pass to `queryClient.query`, except `queryFn`
70
+ * is required unless a default query function has been defined.
71
+ *
72
+ * @template TQueryFnData - The type your `queryFn` resolves to.
73
+ * @template TError - The type of errors your `queryFn` may throw.
74
+ * @template TData - The type `data` ends up as after `select` runs. Defaults to `TQueryFnData` when no
75
+ * `select` is used.
76
+ * @template TQueryData - The type of the data actually held in the query cache — the input to `select` and
77
+ * `placeholderData`. Defaults to, and is usually the same as, `TQueryFnData`.
78
+ * @template TQueryKey - The type of your `queryKey`.
79
+ */
51
80
  export type UsePrefetchQueryOptions<
52
81
  TQueryFnData = unknown,
53
82
  TError = DefaultError,
@@ -58,6 +87,10 @@ export type UsePrefetchQueryOptions<
58
87
  QueryExecuteOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>,
59
88
  'queryFn'
60
89
  > & {
90
+ /**
91
+ * `skipToken` is not allowed as a value here — a prefetch always needs a query function to actually run,
92
+ * unless a default query function has been defined.
93
+ */
61
94
  queryFn?: Exclude<
62
95
  QueryExecuteOptions<
63
96
  TQueryFnData,
@@ -70,6 +103,18 @@ export type UsePrefetchQueryOptions<
70
103
  >
71
104
  }
72
105
 
106
+ /**
107
+ * The options accepted by `usePrefetchInfiniteQuery` — everything you can pass to `queryClient.infiniteQuery`,
108
+ * except `queryFn` is required unless a default query function has been defined.
109
+ *
110
+ * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
111
+ * @template TError - The type of errors your `queryFn` may throw.
112
+ * @template TData - The type `data` ends up as after `select` runs. Defaults to `InfiniteData<TQueryFnData>`,
113
+ * the shape of all fetched pages plus their page params — a prefetch never reads `data` back out, so this
114
+ * parameter only matters if you reuse these options elsewhere with `select` applied.
115
+ * @template TQueryKey - The type of your `queryKey`.
116
+ * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.
117
+ */
73
118
  export type UsePrefetchInfiniteQueryOptions<
74
119
  TQueryFnData = unknown,
75
120
  TError = DefaultError,
@@ -86,6 +131,10 @@ export type UsePrefetchInfiniteQueryOptions<
86
131
  >,
87
132
  'queryFn'
88
133
  > & {
134
+ /**
135
+ * `skipToken` is not allowed as a value here — a prefetch always needs a query function to actually run,
136
+ * unless a default query function has been defined.
137
+ */
89
138
  queryFn?: Exclude<
90
139
  InfiniteQueryExecuteOptions<
91
140
  TQueryFnData,
@@ -98,7 +147,21 @@ export type UsePrefetchInfiniteQueryOptions<
98
147
  >
99
148
  }
100
149
 
150
+ /**
151
+ * {@link UseQueryOptions} with all type parameters set to `any`, useful when the specific types aren't
152
+ * relevant, e.g. when accepting options for any query in a helper function.
153
+ */
101
154
  export type AnyUseQueryOptions = UseQueryOptions<any, any, any, any>
155
+ /**
156
+ * The options accepted by `useQuery`. Same as {@link UseBaseQueryOptions}, minus `suspense` (which
157
+ * `react-query` derives from which hook you call rather than exposing as an option).
158
+ *
159
+ * @template TQueryFnData - The type your `queryFn` resolves to.
160
+ * @template TError - The type of errors your `queryFn` may throw.
161
+ * @template TData - The type `data` ends up as after `select` runs. Defaults to `TQueryFnData` when no
162
+ * `select` is used.
163
+ * @template TQueryKey - The type of your `queryKey`.
164
+ */
102
165
  export interface UseQueryOptions<
103
166
  TQueryFnData = unknown,
104
167
  TError = DefaultError,
@@ -109,12 +172,27 @@ export interface UseQueryOptions<
109
172
  'suspense'
110
173
  > {}
111
174
 
175
+ /**
176
+ * {@link UseSuspenseQueryOptions} with all type parameters set to `any`, useful when the specific types aren't
177
+ * relevant, e.g. when accepting options for any query in a helper function.
178
+ */
112
179
  export type AnyUseSuspenseQueryOptions = UseSuspenseQueryOptions<
113
180
  any,
114
181
  any,
115
182
  any,
116
183
  any
117
184
  >
185
+ /**
186
+ * The options accepted by `useSuspenseQuery`. Same as {@link UseQueryOptions}, minus `enabled`, `throwOnError`,
187
+ * and `placeholderData` — Suspense hooks cannot render a "disabled" or "placeholder" state, so those options
188
+ * don't apply.
189
+ *
190
+ * @template TQueryFnData - The type your `queryFn` resolves to.
191
+ * @template TError - The type of errors your `queryFn` may throw.
192
+ * @template TData - The type `data` ends up as after `select` runs. Defaults to `TQueryFnData` when no
193
+ * `select` is used.
194
+ * @template TQueryKey - The type of your `queryKey`.
195
+ */
118
196
  export interface UseSuspenseQueryOptions<
119
197
  TQueryFnData = unknown,
120
198
  TError = DefaultError,
@@ -124,12 +202,20 @@ export interface UseSuspenseQueryOptions<
124
202
  UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
125
203
  'queryFn' | 'enabled' | 'throwOnError' | 'placeholderData'
126
204
  > {
205
+ /**
206
+ * `skipToken` is not allowed here — Suspense hooks cannot render a "disabled" state, so a query function
207
+ * must always be provided, unless a default query function has been defined.
208
+ */
127
209
  queryFn?: Exclude<
128
210
  UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'],
129
211
  SkipToken
130
212
  >
131
213
  }
132
214
 
215
+ /**
216
+ * {@link UseInfiniteQueryOptions} with all type parameters set to `any`, useful when the specific types aren't
217
+ * relevant, e.g. when accepting options for any query in a helper function.
218
+ */
133
219
  export type AnyUseInfiniteQueryOptions = UseInfiniteQueryOptions<
134
220
  any,
135
221
  any,
@@ -137,6 +223,18 @@ export type AnyUseInfiniteQueryOptions = UseInfiniteQueryOptions<
137
223
  any,
138
224
  any
139
225
  >
226
+ /**
227
+ * The options accepted by `useInfiniteQuery`. Extends {@link InfiniteQueryObserverOptions} from
228
+ * `@tanstack/query-core` with the `react-query`-specific `subscribed` option, minus `suspense` (which
229
+ * `react-query` derives from which hook you call rather than exposing as an option).
230
+ *
231
+ * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
232
+ * @template TError - The type of errors your `queryFn` may throw.
233
+ * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
234
+ * the shape of all fetched pages plus their page params.
235
+ * @template TQueryKey - The type of your `queryKey`.
236
+ * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.
237
+ */
140
238
  export interface UseInfiniteQueryOptions<
141
239
  TQueryFnData = unknown,
142
240
  TError = DefaultError,
@@ -155,13 +253,30 @@ export interface UseInfiniteQueryOptions<
155
253
  > {
156
254
  /**
157
255
  * Set this to `false` to unsubscribe this observer from updates to the query cache.
158
- * Defaults to `true`.
256
+ *
257
+ * @defaultValue true
159
258
  */
160
259
  subscribed?: boolean
161
260
  }
162
261
 
262
+ /**
263
+ * {@link UseSuspenseInfiniteQueryOptions} with all type parameters set to `any`, useful when the specific types
264
+ * aren't relevant, e.g. when accepting options for any query in a helper function.
265
+ */
163
266
  export type AnyUseSuspenseInfiniteQueryOptions =
164
267
  UseSuspenseInfiniteQueryOptions<any, any, any, any, any>
268
+ /**
269
+ * The options accepted by `useSuspenseInfiniteQuery`. Same as {@link UseInfiniteQueryOptions}, minus `enabled`,
270
+ * `throwOnError`, and `placeholderData` — Suspense hooks cannot render a "disabled" or "placeholder" state, so
271
+ * those options don't apply.
272
+ *
273
+ * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
274
+ * @template TError - The type of errors your `queryFn` may throw.
275
+ * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
276
+ * the shape of all fetched pages plus their page params.
277
+ * @template TQueryKey - The type of your `queryKey`.
278
+ * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.
279
+ */
165
280
  export interface UseSuspenseInfiniteQueryOptions<
166
281
  TQueryFnData = unknown,
167
282
  TError = DefaultError,
@@ -172,6 +287,10 @@ export interface UseSuspenseInfiniteQueryOptions<
172
287
  UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>,
173
288
  'queryFn' | 'enabled' | 'throwOnError' | 'placeholderData'
174
289
  > {
290
+ /**
291
+ * `skipToken` is not allowed here — Suspense hooks cannot render a "disabled" state, so a query function
292
+ * must always be provided, unless a default query function has been defined.
293
+ */
175
294
  queryFn?: Exclude<
176
295
  UseInfiniteQueryOptions<
177
296
  TQueryFnData,
@@ -184,16 +303,37 @@ export interface UseSuspenseInfiniteQueryOptions<
184
303
  >
185
304
  }
186
305
 
306
+ /**
307
+ * The result of `useQuery` when `initialData` isn't set — `data` may be `undefined` while the query is
308
+ * `pending`. Re-exports {@link QueryObserverResult} from `@tanstack/query-core`. `useInfiniteQuery` returns
309
+ * {@link UseInfiniteQueryResult} instead.
310
+ *
311
+ * @template TData - The type `data` ends up as after `select` runs.
312
+ * @template TError - The type of errors your `queryFn` may throw.
313
+ */
187
314
  export type UseBaseQueryResult<
188
315
  TData = unknown,
189
316
  TError = DefaultError,
190
317
  > = QueryObserverResult<TData, TError>
191
318
 
319
+ /**
320
+ * The result of `useQuery`. Same as {@link UseBaseQueryResult}.
321
+ *
322
+ * @template TData - The type `data` ends up as after `select` runs.
323
+ * @template TError - The type of errors your `queryFn` may throw.
324
+ */
192
325
  export type UseQueryResult<
193
326
  TData = unknown,
194
327
  TError = DefaultError,
195
328
  > = UseBaseQueryResult<TData, TError>
196
329
 
330
+ /**
331
+ * The result of `useSuspenseQuery`. Same as {@link DefinedUseQueryResult}, minus `isPlaceholderData` — always
332
+ * `false` on that type, so this drops the dead field rather than an active state.
333
+ *
334
+ * @template TData - The type `data` ends up as after `select` runs.
335
+ * @template TError - The type of errors your `queryFn` may throw.
336
+ */
197
337
  export type UseSuspenseQueryResult<
198
338
  TData = unknown,
199
339
  TError = DefaultError,
@@ -202,21 +342,50 @@ export type UseSuspenseQueryResult<
202
342
  'isPlaceholderData'
203
343
  >
204
344
 
345
+ /**
346
+ * The result of `useQuery` when `initialData` is set, or of `useSuspenseQuery` before the `isPlaceholderData`
347
+ * omission — `data` is never `undefined`. Re-exports {@link DefinedQueryObserverResult} from
348
+ * `@tanstack/query-core`.
349
+ *
350
+ * @template TData - The type `data` ends up as after `select` runs.
351
+ * @template TError - The type of errors your `queryFn` may throw.
352
+ */
205
353
  export type DefinedUseQueryResult<
206
354
  TData = unknown,
207
355
  TError = DefaultError,
208
356
  > = DefinedQueryObserverResult<TData, TError>
209
357
 
358
+ /**
359
+ * The result of `useInfiniteQuery` when `initialData` isn't set — `data` may be `undefined` while the query is
360
+ * `pending`. Re-exports {@link InfiniteQueryObserverResult} from `@tanstack/query-core`.
361
+ *
362
+ * @template TData - The type `data` ends up as after `select` runs.
363
+ * @template TError - The type of errors your `queryFn` may throw.
364
+ */
210
365
  export type UseInfiniteQueryResult<
211
366
  TData = unknown,
212
367
  TError = DefaultError,
213
368
  > = InfiniteQueryObserverResult<TData, TError>
214
369
 
370
+ /**
371
+ * The result of `useInfiniteQuery` when `initialData` is set — `data` is never `undefined`. Re-exports
372
+ * {@link DefinedInfiniteQueryObserverResult} from `@tanstack/query-core`.
373
+ *
374
+ * @template TData - The type `data` ends up as after `select` runs.
375
+ * @template TError - The type of errors your `queryFn` may throw.
376
+ */
215
377
  export type DefinedUseInfiniteQueryResult<
216
378
  TData = unknown,
217
379
  TError = DefaultError,
218
380
  > = DefinedInfiniteQueryObserverResult<TData, TError>
219
381
 
382
+ /**
383
+ * The result of `useSuspenseInfiniteQuery`. Same as {@link DefinedUseInfiniteQueryResult}, minus
384
+ * `isPlaceholderData` — Suspense hooks never render placeholder data.
385
+ *
386
+ * @template TData - The type `data` ends up as after `select` runs.
387
+ * @template TError - The type of errors your `queryFn` may throw.
388
+ */
220
389
  export type UseSuspenseInfiniteQueryResult<
221
390
  TData = unknown,
222
391
  TError = DefaultError,
@@ -225,7 +394,21 @@ export type UseSuspenseInfiniteQueryResult<
225
394
  'isPlaceholderData'
226
395
  >
227
396
 
397
+ /**
398
+ * {@link UseMutationOptions} with all type parameters set to `any`, useful when the specific types aren't
399
+ * relevant, e.g. when accepting options for any mutation in a helper function.
400
+ */
228
401
  export type AnyUseMutationOptions = UseMutationOptions<any, any, any, any>
402
+ /**
403
+ * The options accepted by `useMutation`. Same as {@link MutationObserverOptions} from `@tanstack/query-core`,
404
+ * minus the internal `_defaulted` flag.
405
+ *
406
+ * @template TData - The type your mutation function resolves to.
407
+ * @template TError - The type of errors your mutation function may throw.
408
+ * @template TVariables - The type of the variable passed to `mutate`/`mutateAsync`.
409
+ * @template TOnMutateResult - The type returned by `onMutate`, passed to `onSuccess`/`onError`/`onSettled` as
410
+ * their `onMutateResult` parameter — useful for optimistic-update rollback data.
411
+ */
229
412
  export interface UseMutationOptions<
230
413
  TData = unknown,
231
414
  TError = DefaultError,
@@ -236,6 +419,17 @@ export interface UseMutationOptions<
236
419
  '_defaulted'
237
420
  > {}
238
421
 
422
+ /**
423
+ * The type of `mutate`, as returned by `useMutation`. Forwards the variables (and an optional per-call
424
+ * `onSuccess`/`onError`/`onSettled`) to the underlying `mutate` call. Fire-and-forget — errors are surfaced
425
+ * through the mutation result, not thrown.
426
+ *
427
+ * @template TData - The type your mutation function resolves to.
428
+ * @template TError - The type of errors your mutation function may throw.
429
+ * @template TVariables - The type of the variable passed to `mutate`.
430
+ * @template TOnMutateResult - The type returned by `onMutate`, passed to `onSuccess`/`onError`/`onSettled` as
431
+ * their `onMutateResult` parameter — useful for optimistic-update rollback data.
432
+ */
239
433
  export type UseMutateFunction<
240
434
  TData = unknown,
241
435
  TError = DefaultError,
@@ -247,6 +441,16 @@ export type UseMutateFunction<
247
441
  >
248
442
  ) => void
249
443
 
444
+ /**
445
+ * The type of `mutateAsync`, as returned by `useMutation`. Similar to {@link UseMutateFunction}, but returns a
446
+ * promise which can be awaited.
447
+ *
448
+ * @template TData - The type your mutation function resolves to.
449
+ * @template TError - The type of errors your mutation function may throw.
450
+ * @template TVariables - The type of the variable passed to `mutateAsync`.
451
+ * @template TOnMutateResult - The type returned by `onMutate`, passed to `onSuccess`/`onError`/`onSettled` as
452
+ * their `onMutateResult` parameter — useful for optimistic-update rollback data.
453
+ */
250
454
  export type UseMutateAsyncFunction<
251
455
  TData = unknown,
252
456
  TError = DefaultError,
@@ -254,6 +458,16 @@ export type UseMutateAsyncFunction<
254
458
  TOnMutateResult = unknown,
255
459
  > = MutateFunction<TData, TError, TVariables, TOnMutateResult>
256
460
 
461
+ /**
462
+ * The result of `useMutation`. Same as {@link MutationObserverResult} from `@tanstack/query-core`, with
463
+ * `mutate` narrowed to the fire-and-forget {@link UseMutateFunction} signature, plus the added `mutateAsync`.
464
+ *
465
+ * @template TData - The type your mutation function resolves to.
466
+ * @template TError - The type of errors your mutation function may throw.
467
+ * @template TVariables - The type of the variable passed to `mutate`/`mutateAsync`.
468
+ * @template TOnMutateResult - The type returned by `onMutate`, passed to `onSuccess`/`onError`/`onSettled` as
469
+ * their `onMutateResult` parameter — useful for optimistic-update rollback data.
470
+ */
257
471
  export type UseBaseMutationResult<
258
472
  TData = unknown,
259
473
  TError = DefaultError,
@@ -263,6 +477,9 @@ export type UseBaseMutationResult<
263
477
  MutationObserverResult<TData, TError, TVariables, TOnMutateResult>,
264
478
  { mutate: UseMutateFunction<TData, TError, TVariables, TOnMutateResult> }
265
479
  > & {
480
+ /**
481
+ * Similar to `mutate`, but returns a promise which can be awaited.
482
+ */
266
483
  mutateAsync: UseMutateAsyncFunction<
267
484
  TData,
268
485
  TError,
@@ -271,6 +488,15 @@ export type UseBaseMutationResult<
271
488
  >
272
489
  }
273
490
 
491
+ /**
492
+ * The result of `useMutation`. Same as {@link UseBaseMutationResult}.
493
+ *
494
+ * @template TData - The type your mutation function resolves to.
495
+ * @template TError - The type of errors your mutation function may throw.
496
+ * @template TVariables - The type of the variable passed to `mutate`/`mutateAsync`.
497
+ * @template TOnMutateResult - The type returned by `onMutate`, passed to `onSuccess`/`onError`/`onSettled` as
498
+ * their `onMutateResult` parameter — useful for optimistic-update rollback data.
499
+ */
274
500
  export type UseMutationResult<
275
501
  TData = unknown,
276
502
  TError = DefaultError,