@tanstack/react-query 5.0.0-alpha.7 → 5.0.0-alpha.71

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 (290) hide show
  1. package/build/codemods/__testfixtures__/default-import.input.tsx +94 -0
  2. package/build/codemods/__testfixtures__/default-import.output.tsx +96 -0
  3. package/build/codemods/__testfixtures__/named-import.input.tsx +96 -0
  4. package/build/codemods/__testfixtures__/named-import.output.tsx +98 -0
  5. package/build/codemods/__testfixtures__/namespaced-import.input.tsx +86 -0
  6. package/build/codemods/__testfixtures__/namespaced-import.output.tsx +88 -0
  7. package/build/codemods/__testfixtures__/parameter-is-identifier.input.tsx +49 -0
  8. package/build/codemods/__testfixtures__/parameter-is-identifier.output.tsx +49 -0
  9. package/build/codemods/__testfixtures__/parameter-is-object-expression.input.tsx +128 -0
  10. package/build/codemods/__testfixtures__/parameter-is-object-expression.output.tsx +175 -0
  11. package/build/codemods/__testfixtures__/replace-import-specifier.input.tsx +10 -0
  12. package/build/codemods/__testfixtures__/replace-import-specifier.output.tsx +10 -0
  13. package/build/codemods/__testfixtures__/type-arguments.input.tsx +25 -0
  14. package/build/codemods/__testfixtures__/type-arguments.output.tsx +31 -0
  15. package/build/codemods/__tests__/key-transformation.test.js +32 -0
  16. package/build/codemods/__tests__/replace-import-specifier.test.js +12 -0
  17. package/build/codemods/remove-overloads/__testfixtures__/default-import.input.tsx +199 -0
  18. package/build/codemods/remove-overloads/__testfixtures__/default-import.output.tsx +484 -0
  19. package/build/codemods/remove-overloads/__tests__/remove-overloads.test.js +6 -0
  20. package/build/codemods/remove-overloads/remove-overloads.js +59 -0
  21. package/build/codemods/remove-overloads/transformers/filter-aware-usage-transformer.js +153 -0
  22. package/build/codemods/remove-overloads/transformers/query-fn-aware-usage-transformer.js +188 -0
  23. package/build/codemods/remove-overloads/utils/index.js +124 -0
  24. package/build/codemods/remove-overloads/utils/unknown-usage-error.js +27 -0
  25. package/build/codemods/src/utils/index.js +205 -0
  26. package/build/codemods/src/v4/key-transformation.js +138 -0
  27. package/build/codemods/src/v4/replace-import-specifier.js +25 -0
  28. package/build/codemods/transformers/query-cache-transformer.js +116 -0
  29. package/build/codemods/transformers/query-client-transformer.js +48 -0
  30. package/build/codemods/transformers/use-query-like-transformer.js +32 -0
  31. package/build/codemods/utils/replacers/key-replacer.js +164 -0
  32. package/build/lib/HydrationBoundary.cjs +50 -0
  33. package/build/lib/{HydrationBoundary.mjs.map → HydrationBoundary.cjs.map} +1 -1
  34. package/build/lib/HydrationBoundary.d.ts +1 -0
  35. package/build/lib/HydrationBoundary.d.ts.map +1 -0
  36. package/build/lib/HydrationBoundary.js +9 -29
  37. package/build/lib/HydrationBoundary.js.map +1 -1
  38. package/build/lib/HydrationBoundary.legacy.cjs +50 -0
  39. package/build/lib/HydrationBoundary.legacy.cjs.map +1 -0
  40. package/build/lib/{HydrationBoundary.esm.js → HydrationBoundary.legacy.js} +3 -2
  41. package/build/lib/HydrationBoundary.legacy.js.map +1 -0
  42. package/build/lib/QueryClientProvider.cjs +54 -0
  43. package/build/lib/QueryClientProvider.cjs.map +1 -0
  44. package/build/lib/QueryClientProvider.d.ts +2 -1
  45. package/build/lib/QueryClientProvider.d.ts.map +1 -0
  46. package/build/lib/QueryClientProvider.js +7 -29
  47. package/build/lib/QueryClientProvider.js.map +1 -1
  48. package/build/lib/QueryClientProvider.legacy.cjs +54 -0
  49. package/build/lib/QueryClientProvider.legacy.cjs.map +1 -0
  50. package/build/lib/{QueryClientProvider.esm.js → QueryClientProvider.legacy.js} +2 -1
  51. package/build/lib/QueryClientProvider.legacy.js.map +1 -0
  52. package/build/lib/QueryErrorResetBoundary.cjs +60 -0
  53. package/build/lib/{QueryErrorResetBoundary.mjs.map → QueryErrorResetBoundary.cjs.map} +1 -1
  54. package/build/lib/QueryErrorResetBoundary.d.ts +1 -0
  55. package/build/lib/QueryErrorResetBoundary.d.ts.map +1 -0
  56. package/build/lib/QueryErrorResetBoundary.js +7 -28
  57. package/build/lib/QueryErrorResetBoundary.js.map +1 -1
  58. package/build/lib/QueryErrorResetBoundary.legacy.cjs +60 -0
  59. package/build/lib/QueryErrorResetBoundary.legacy.cjs.map +1 -0
  60. package/build/lib/{QueryErrorResetBoundary.esm.js → QueryErrorResetBoundary.legacy.js} +2 -1
  61. package/build/lib/QueryErrorResetBoundary.legacy.js.map +1 -0
  62. package/build/lib/__tests__/HydrationBoundary.test.d.ts +1 -0
  63. package/build/lib/__tests__/HydrationBoundary.test.d.ts.map +1 -0
  64. package/build/lib/__tests__/QueryClientProvider.test.d.ts +1 -0
  65. package/build/lib/__tests__/QueryClientProvider.test.d.ts.map +1 -0
  66. package/build/lib/__tests__/QueryResetErrorBoundary.test.d.ts +1 -0
  67. package/build/lib/__tests__/QueryResetErrorBoundary.test.d.ts.map +1 -0
  68. package/build/lib/__tests__/ssr-hydration.test.d.ts +1 -0
  69. package/build/lib/__tests__/ssr-hydration.test.d.ts.map +1 -0
  70. package/build/lib/__tests__/ssr.test.d.ts +1 -0
  71. package/build/lib/__tests__/ssr.test.d.ts.map +1 -0
  72. package/build/lib/__tests__/suspense.test.d.ts +1 -0
  73. package/build/lib/__tests__/suspense.test.d.ts.map +1 -0
  74. package/build/lib/__tests__/useInfiniteQuery.test.d.ts +1 -0
  75. package/build/lib/__tests__/useInfiniteQuery.test.d.ts.map +1 -0
  76. package/build/lib/__tests__/useInfiniteQuery.type.test.d.ts +1 -0
  77. package/build/lib/__tests__/useInfiniteQuery.type.test.d.ts.map +1 -0
  78. package/build/lib/__tests__/useIsFetching.test.d.ts +1 -0
  79. package/build/lib/__tests__/useIsFetching.test.d.ts.map +1 -0
  80. package/build/lib/__tests__/useMutation.test.d.ts +1 -0
  81. package/build/lib/__tests__/useMutation.test.d.ts.map +1 -0
  82. package/build/lib/__tests__/useMutationState.test.d.ts +1 -0
  83. package/build/lib/__tests__/useMutationState.test.d.ts.map +1 -0
  84. package/build/lib/__tests__/useQueries.test.d.ts +1 -0
  85. package/build/lib/__tests__/useQueries.test.d.ts.map +1 -0
  86. package/build/lib/__tests__/useQuery.test.d.ts +1 -0
  87. package/build/lib/__tests__/useQuery.test.d.ts.map +1 -0
  88. package/build/lib/__tests__/useQuery.types.test.d.ts +1 -0
  89. package/build/lib/__tests__/useQuery.types.test.d.ts.map +1 -0
  90. package/build/lib/__tests__/utils.d.ts +3 -2
  91. package/build/lib/__tests__/utils.d.ts.map +1 -0
  92. package/build/lib/errorBoundaryUtils.cjs +51 -0
  93. package/build/lib/errorBoundaryUtils.cjs.map +1 -0
  94. package/build/lib/errorBoundaryUtils.d.ts +4 -3
  95. package/build/lib/errorBoundaryUtils.d.ts.map +1 -0
  96. package/build/lib/errorBoundaryUtils.js +8 -30
  97. package/build/lib/errorBoundaryUtils.js.map +1 -1
  98. package/build/lib/errorBoundaryUtils.legacy.cjs +51 -0
  99. package/build/lib/errorBoundaryUtils.legacy.cjs.map +1 -0
  100. package/build/lib/{errorBoundaryUtils.esm.js → errorBoundaryUtils.legacy.js} +6 -5
  101. package/build/lib/errorBoundaryUtils.legacy.js.map +1 -0
  102. package/build/lib/index.cjs +40 -0
  103. package/build/lib/index.cjs.map +1 -0
  104. package/build/lib/index.d.ts +2 -0
  105. package/build/lib/index.d.ts.map +1 -0
  106. package/build/lib/index.js +12 -37
  107. package/build/lib/index.js.map +1 -1
  108. package/build/lib/index.legacy.cjs +40 -0
  109. package/build/lib/index.legacy.cjs.map +1 -0
  110. package/build/lib/index.legacy.js +13 -0
  111. package/build/lib/index.legacy.js.map +1 -0
  112. package/build/lib/isRestoring.cjs +31 -0
  113. package/build/lib/isRestoring.cjs.map +1 -0
  114. package/build/lib/isRestoring.d.ts +1 -0
  115. package/build/lib/isRestoring.d.ts.map +1 -0
  116. package/build/lib/isRestoring.js +5 -26
  117. package/build/lib/isRestoring.js.map +1 -1
  118. package/build/lib/isRestoring.legacy.cjs +31 -0
  119. package/build/lib/isRestoring.legacy.cjs.map +1 -0
  120. package/build/lib/{isRestoring.esm.js → isRestoring.legacy.js} +2 -1
  121. package/build/lib/isRestoring.legacy.js.map +1 -0
  122. package/build/lib/queryOptions.cjs +8 -0
  123. package/build/lib/queryOptions.cjs.map +1 -0
  124. package/build/lib/queryOptions.d.ts +11 -0
  125. package/build/lib/queryOptions.d.ts.map +1 -0
  126. package/build/lib/queryOptions.js +6 -0
  127. package/build/lib/queryOptions.js.map +1 -0
  128. package/build/lib/queryOptions.legacy.cjs +8 -0
  129. package/build/lib/queryOptions.legacy.cjs.map +1 -0
  130. package/build/lib/queryOptions.legacy.js +6 -0
  131. package/build/lib/queryOptions.legacy.js.map +1 -0
  132. package/build/lib/suspense.cjs +22 -0
  133. package/build/lib/suspense.cjs.map +1 -0
  134. package/build/lib/suspense.d.ts +3 -5
  135. package/build/lib/suspense.d.ts.map +1 -0
  136. package/build/lib/suspense.js +3 -15
  137. package/build/lib/suspense.js.map +1 -1
  138. package/build/lib/{suspense.esm.js → suspense.legacy.cjs} +8 -10
  139. package/build/lib/suspense.legacy.cjs.map +1 -0
  140. package/build/lib/{suspense.mjs → suspense.legacy.js} +3 -10
  141. package/build/lib/suspense.legacy.js.map +1 -0
  142. package/build/lib/types.d.ts +11 -10
  143. package/build/lib/types.d.ts.map +1 -0
  144. package/build/lib/useBaseQuery.cjs +80 -0
  145. package/build/lib/useBaseQuery.cjs.map +1 -0
  146. package/build/lib/useBaseQuery.d.ts +1 -0
  147. package/build/lib/useBaseQuery.d.ts.map +1 -0
  148. package/build/lib/useBaseQuery.js +30 -54
  149. package/build/lib/useBaseQuery.js.map +1 -1
  150. package/build/lib/useBaseQuery.legacy.cjs +80 -0
  151. package/build/lib/useBaseQuery.legacy.cjs.map +1 -0
  152. package/build/lib/{useBaseQuery.mjs → useBaseQuery.legacy.js} +16 -19
  153. package/build/lib/useBaseQuery.legacy.js.map +1 -0
  154. package/build/lib/useInfiniteQuery.cjs +15 -0
  155. package/build/lib/useInfiniteQuery.cjs.map +1 -0
  156. package/build/lib/useInfiniteQuery.d.ts +1 -0
  157. package/build/lib/useInfiniteQuery.d.ts.map +1 -0
  158. package/build/lib/useInfiniteQuery.js +6 -7
  159. package/build/lib/useInfiniteQuery.js.map +1 -1
  160. package/build/lib/useInfiniteQuery.legacy.cjs +15 -0
  161. package/build/lib/useInfiniteQuery.legacy.cjs.map +1 -0
  162. package/build/lib/{useInfiniteQuery.esm.js → useInfiniteQuery.legacy.js} +3 -2
  163. package/build/lib/useInfiniteQuery.legacy.js.map +1 -0
  164. package/build/lib/useIsFetching.cjs +34 -0
  165. package/build/lib/useIsFetching.cjs.map +1 -0
  166. package/build/lib/useIsFetching.d.ts +1 -0
  167. package/build/lib/useIsFetching.d.ts.map +1 -0
  168. package/build/lib/useIsFetching.js +7 -27
  169. package/build/lib/useIsFetching.js.map +1 -1
  170. package/build/lib/useIsFetching.legacy.cjs +34 -0
  171. package/build/lib/useIsFetching.legacy.cjs.map +1 -0
  172. package/build/lib/{useIsFetching.esm.js → useIsFetching.legacy.js} +3 -2
  173. package/build/lib/useIsFetching.legacy.js.map +1 -0
  174. package/build/lib/useMutation.cjs +54 -0
  175. package/build/lib/useMutation.cjs.map +1 -0
  176. package/build/lib/useMutation.d.ts +1 -0
  177. package/build/lib/useMutation.d.ts.map +1 -0
  178. package/build/lib/useMutation.js +12 -32
  179. package/build/lib/useMutation.js.map +1 -1
  180. package/build/lib/useMutation.legacy.cjs +54 -0
  181. package/build/lib/useMutation.legacy.cjs.map +1 -0
  182. package/build/lib/{useMutation.esm.js → useMutation.legacy.js} +5 -4
  183. package/build/lib/useMutation.legacy.js.map +1 -0
  184. package/build/lib/useMutationState.cjs +60 -0
  185. package/build/lib/useMutationState.cjs.map +1 -0
  186. package/build/lib/useMutationState.d.ts +4 -3
  187. package/build/lib/useMutationState.d.ts.map +1 -0
  188. package/build/lib/useMutationState.js +13 -34
  189. package/build/lib/useMutationState.js.map +1 -1
  190. package/build/lib/useMutationState.legacy.cjs +60 -0
  191. package/build/lib/useMutationState.legacy.cjs.map +1 -0
  192. package/build/lib/{useMutationState.esm.js → useMutationState.legacy.js} +3 -2
  193. package/build/lib/useMutationState.legacy.js.map +1 -0
  194. package/build/lib/useQueries.cjs +99 -0
  195. package/build/lib/useQueries.cjs.map +1 -0
  196. package/build/lib/useQueries.d.ts +10 -8
  197. package/build/lib/useQueries.d.ts.map +1 -0
  198. package/build/lib/useQueries.js +52 -67
  199. package/build/lib/useQueries.js.map +1 -1
  200. package/build/lib/useQueries.legacy.cjs +102 -0
  201. package/build/lib/useQueries.legacy.cjs.map +1 -0
  202. package/build/lib/{useQueries.esm.js → useQueries.legacy.js} +37 -28
  203. package/build/lib/useQueries.legacy.js.map +1 -0
  204. package/build/lib/useQuery.cjs +14 -0
  205. package/build/lib/useQuery.cjs.map +1 -0
  206. package/build/lib/useQuery.d.ts +3 -8
  207. package/build/lib/useQuery.d.ts.map +1 -0
  208. package/build/lib/useQuery.js +5 -6
  209. package/build/lib/useQuery.js.map +1 -1
  210. package/build/lib/useQuery.legacy.cjs +14 -0
  211. package/build/lib/useQuery.legacy.cjs.map +1 -0
  212. package/build/lib/{useQuery.esm.js → useQuery.legacy.js} +3 -2
  213. package/build/lib/useQuery.legacy.js.map +1 -0
  214. package/build/lib/{utils.mjs → utils.cjs} +4 -2
  215. package/build/lib/{utils.mjs.map → utils.cjs.map} +1 -1
  216. package/build/lib/utils.d.ts +1 -0
  217. package/build/lib/utils.d.ts.map +1 -0
  218. package/build/lib/utils.js +1 -3
  219. package/build/lib/utils.js.map +1 -1
  220. package/build/lib/utils.legacy.cjs +12 -0
  221. package/build/lib/utils.legacy.cjs.map +1 -0
  222. package/build/lib/{utils.esm.js → utils.legacy.js} +1 -1
  223. package/build/lib/utils.legacy.js.map +1 -0
  224. package/package.json +25 -15
  225. package/src/__tests__/QueryResetErrorBoundary.test.tsx +752 -620
  226. package/src/__tests__/ssr-hydration.test.tsx +2 -2
  227. package/src/__tests__/suspense.test.tsx +6 -88
  228. package/src/__tests__/useInfiniteQuery.type.test.tsx +0 -27
  229. package/src/__tests__/useMutation.test.tsx +4 -4
  230. package/src/__tests__/useMutationState.test.tsx +23 -0
  231. package/src/__tests__/useQueries.test.tsx +206 -83
  232. package/src/__tests__/useQuery.test.tsx +246 -338
  233. package/src/__tests__/useQuery.types.test.tsx +21 -0
  234. package/src/errorBoundaryUtils.ts +6 -5
  235. package/src/index.ts +1 -0
  236. package/src/queryOptions.ts +42 -0
  237. package/src/suspense.ts +9 -15
  238. package/src/useBaseQuery.ts +12 -23
  239. package/src/useInfiniteQuery.ts +1 -0
  240. package/src/useIsFetching.ts +1 -0
  241. package/src/useMutation.ts +2 -1
  242. package/src/useMutationState.ts +4 -3
  243. package/src/useQueries.ts +44 -26
  244. package/src/useQuery.ts +5 -17
  245. package/build/lib/HydrationBoundary.esm.js.map +0 -1
  246. package/build/lib/HydrationBoundary.mjs +0 -28
  247. package/build/lib/QueryClientProvider.esm.js.map +0 -1
  248. package/build/lib/QueryClientProvider.mjs +0 -30
  249. package/build/lib/QueryClientProvider.mjs.map +0 -1
  250. package/build/lib/QueryErrorResetBoundary.esm.js.map +0 -1
  251. package/build/lib/QueryErrorResetBoundary.mjs +0 -37
  252. package/build/lib/errorBoundaryUtils.esm.js.map +0 -1
  253. package/build/lib/errorBoundaryUtils.mjs +0 -27
  254. package/build/lib/errorBoundaryUtils.mjs.map +0 -1
  255. package/build/lib/index.esm.js +0 -12
  256. package/build/lib/index.esm.js.map +0 -1
  257. package/build/lib/index.mjs +0 -12
  258. package/build/lib/index.mjs.map +0 -1
  259. package/build/lib/isRestoring.esm.js.map +0 -1
  260. package/build/lib/isRestoring.mjs +0 -8
  261. package/build/lib/isRestoring.mjs.map +0 -1
  262. package/build/lib/suspense.esm.js.map +0 -1
  263. package/build/lib/suspense.mjs.map +0 -1
  264. package/build/lib/useBaseQuery.esm.js +0 -62
  265. package/build/lib/useBaseQuery.esm.js.map +0 -1
  266. package/build/lib/useBaseQuery.mjs.map +0 -1
  267. package/build/lib/useInfiniteQuery.esm.js.map +0 -1
  268. package/build/lib/useInfiniteQuery.mjs +0 -12
  269. package/build/lib/useInfiniteQuery.mjs.map +0 -1
  270. package/build/lib/useIsFetching.esm.js.map +0 -1
  271. package/build/lib/useIsFetching.mjs +0 -12
  272. package/build/lib/useIsFetching.mjs.map +0 -1
  273. package/build/lib/useMutation.esm.js.map +0 -1
  274. package/build/lib/useMutation.mjs +0 -32
  275. package/build/lib/useMutation.mjs.map +0 -1
  276. package/build/lib/useMutationState.esm.js.map +0 -1
  277. package/build/lib/useMutationState.mjs +0 -37
  278. package/build/lib/useMutationState.mjs.map +0 -1
  279. package/build/lib/useQueries.esm.js.map +0 -1
  280. package/build/lib/useQueries.mjs +0 -69
  281. package/build/lib/useQueries.mjs.map +0 -1
  282. package/build/lib/useQuery.esm.js.map +0 -1
  283. package/build/lib/useQuery.mjs +0 -11
  284. package/build/lib/useQuery.mjs.map +0 -1
  285. package/build/lib/utils.esm.js.map +0 -1
  286. package/build/umd/index.development.js +0 -3040
  287. package/build/umd/index.development.js.map +0 -1
  288. package/build/umd/index.production.js +0 -2
  289. package/build/umd/index.production.js.map +0 -1
  290. /package/src/{isRestoring.tsx → isRestoring.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react'
2
2
  import ReactDOM from 'react-dom'
3
- import ReactDOMTestUtils from 'react-dom/test-utils'
4
- import ReactDOMServer from 'react-dom/server'
3
+ import * as ReactDOMTestUtils from 'react-dom/test-utils'
4
+ import * as ReactDOMServer from 'react-dom/server'
5
5
  // eslint-disable-next-line import/no-unresolved -- types only for module augmentation
6
6
  import type {} from 'react-dom/next'
7
7
  import { vi } from 'vitest'
@@ -190,88 +190,6 @@ describe("useQuery's in Suspense mode", () => {
190
190
  expect(queryCache.find({ queryKey: key })?.getObserversCount()).toBe(0)
191
191
  })
192
192
 
193
- it('should call onSuccess on the first successful call', async () => {
194
- const key = queryKey()
195
-
196
- const successFn = vi.fn()
197
-
198
- function Page() {
199
- useQuery({
200
- queryKey: [key],
201
- queryFn: async () => {
202
- await sleep(10)
203
- return key
204
- },
205
- suspense: true,
206
- select: () => 'selected',
207
- onSuccess: successFn,
208
- })
209
-
210
- return <>rendered</>
211
- }
212
-
213
- const rendered = renderWithClient(
214
- queryClient,
215
- <React.Suspense fallback="loading">
216
- <Page />
217
- </React.Suspense>,
218
- )
219
-
220
- await waitFor(() => rendered.getByText('rendered'))
221
-
222
- await waitFor(() => expect(successFn).toHaveBeenCalledTimes(1))
223
- await waitFor(() => expect(successFn).toHaveBeenCalledWith('selected'))
224
- })
225
-
226
- it('should call every onSuccess handler within a suspense boundary', async () => {
227
- const key = queryKey()
228
-
229
- const successFn1 = vi.fn()
230
- const successFn2 = vi.fn()
231
-
232
- function FirstComponent() {
233
- useQuery({
234
- queryKey: key,
235
- queryFn: () => {
236
- sleep(10)
237
- return 'data'
238
- },
239
- suspense: true,
240
- onSuccess: successFn1,
241
- })
242
-
243
- return <span>first</span>
244
- }
245
-
246
- function SecondComponent() {
247
- useQuery({
248
- queryKey: key,
249
- queryFn: () => {
250
- sleep(10)
251
- return 'data'
252
- },
253
-
254
- suspense: true,
255
- onSuccess: successFn2,
256
- })
257
-
258
- return <span>second</span>
259
- }
260
-
261
- const rendered = renderWithClient(
262
- queryClient,
263
- <React.Suspense fallback="loading">
264
- <FirstComponent />
265
- <SecondComponent />
266
- </React.Suspense>,
267
- )
268
-
269
- await waitFor(() => rendered.getByText('second'))
270
-
271
- await waitFor(() => expect(successFn1).toHaveBeenCalledTimes(1))
272
- await waitFor(() => expect(successFn2).toHaveBeenCalledTimes(1))
273
- })
274
-
275
193
  // https://github.com/tannerlinsley/react-query/issues/468
276
194
  it('should reset error state if new component instances are mounted', async () => {
277
195
  const consoleMock = vi
@@ -616,7 +534,7 @@ describe("useQuery's in Suspense mode", () => {
616
534
  consoleMock.mockRestore()
617
535
  })
618
536
 
619
- it('should not throw errors to the error boundary when throwErrors: false', async () => {
537
+ it('should not throw errors to the error boundary when throwOnError: false', async () => {
620
538
  const key = queryKey()
621
539
 
622
540
  function Page() {
@@ -628,7 +546,7 @@ describe("useQuery's in Suspense mode", () => {
628
546
  },
629
547
  retry: false,
630
548
  suspense: true,
631
- throwErrors: false,
549
+ throwOnError: false,
632
550
  })
633
551
  return <div>rendered</div>
634
552
  }
@@ -655,7 +573,7 @@ describe("useQuery's in Suspense mode", () => {
655
573
  await waitFor(() => rendered.getByText('rendered'))
656
574
  })
657
575
 
658
- it('should throw errors to the error boundary when a throwErrors function returns true', async () => {
576
+ it('should throw errors to the error boundary when a throwOnError function returns true', async () => {
659
577
  const consoleMock = vi
660
578
  .spyOn(console, 'error')
661
579
  .mockImplementation(() => undefined)
@@ -670,7 +588,7 @@ describe("useQuery's in Suspense mode", () => {
670
588
  },
671
589
  retry: false,
672
590
  suspense: true,
673
- throwErrors: (err) => err.message !== 'Local Error',
591
+ throwOnError: (err) => err.message !== 'Local Error',
674
592
  })
675
593
  return <div>rendered</div>
676
594
  }
@@ -698,7 +616,7 @@ describe("useQuery's in Suspense mode", () => {
698
616
  consoleMock.mockRestore()
699
617
  })
700
618
 
701
- it('should not throw errors to the error boundary when a throwErrors function returns false', async () => {
619
+ it('should not throw errors to the error boundary when a throwOnError function returns false', async () => {
702
620
  const key = queryKey()
703
621
 
704
622
  function Page() {
@@ -710,7 +628,7 @@ describe("useQuery's in Suspense mode", () => {
710
628
  },
711
629
  retry: false,
712
630
  suspense: true,
713
- throwErrors: (err) => err.message !== 'Local Error',
631
+ throwOnError: (err) => err.message !== 'Local Error',
714
632
  })
715
633
  return <div>rendered</div>
716
634
  }
@@ -128,33 +128,6 @@ describe('select', () => {
128
128
  return result
129
129
  })
130
130
  })
131
- it('should pass transformed data to onSuccess', () => {
132
- doNotExecute(() => {
133
- const infiniteQuery = useInfiniteQuery({
134
- queryKey: ['key'],
135
- queryFn: ({ pageParam }) => {
136
- return pageParam * 5
137
- },
138
- defaultPageParam: 1,
139
- getNextPageParam: () => undefined,
140
- select: (data) => {
141
- return {
142
- ...data,
143
- pages: data.pages.map((page) => page.toString()),
144
- }
145
- },
146
- onSuccess: (data) => {
147
- const result: Expect<Equal<InfiniteData<string>, typeof data>> = true
148
- doNotExecute(() => result)
149
- },
150
- })
151
-
152
- const result: Expect<
153
- Equal<InfiniteData<string> | undefined, (typeof infiniteQuery)['data']>
154
- > = true
155
- return result
156
- })
157
- })
158
131
  })
159
132
  describe('getNextPageParam / getPreviousPageParam', () => {
160
133
  it('should get typed params', () => {
@@ -688,7 +688,7 @@ describe('useMutation', () => {
688
688
  fireEvent.click(getByText('unmount'))
689
689
  })
690
690
 
691
- it('should be able to throw an error when throwErrors is set to true', async () => {
691
+ it('should be able to throw an error when throwOnError is set to true', async () => {
692
692
  const consoleMock = vi
693
693
  .spyOn(console, 'error')
694
694
  .mockImplementation(() => undefined)
@@ -699,7 +699,7 @@ describe('useMutation', () => {
699
699
  err.stack = ''
700
700
  return Promise.reject(err)
701
701
  },
702
- throwErrors: true,
702
+ throwOnError: true,
703
703
  })
704
704
 
705
705
  return (
@@ -735,7 +735,7 @@ describe('useMutation', () => {
735
735
  consoleMock.mockRestore()
736
736
  })
737
737
 
738
- it('should be able to throw an error when throwErrors is a function that returns true', async () => {
738
+ it('should be able to throw an error when throwOnError is a function that returns true', async () => {
739
739
  const consoleMock = vi
740
740
  .spyOn(console, 'error')
741
741
  .mockImplementation(() => undefined)
@@ -747,7 +747,7 @@ describe('useMutation', () => {
747
747
  err.stack = ''
748
748
  return Promise.reject(err)
749
749
  },
750
- throwErrors: () => {
750
+ throwOnError: () => {
751
751
  boundary = !boundary
752
752
  return !boundary
753
753
  },
@@ -4,10 +4,12 @@ import { useIsMutating, useMutationState } from '../useMutationState'
4
4
  import { useMutation } from '../useMutation'
5
5
  import {
6
6
  createQueryClient,
7
+ doNotExecute,
7
8
  renderWithClient,
8
9
  setActTimeout,
9
10
  sleep,
10
11
  } from './utils'
12
+ import type { MutationState, MutationStatus } from '@tanstack/query-core'
11
13
 
12
14
  describe('useIsMutating', () => {
13
15
  it('should return the number of fetching mutations', async () => {
@@ -172,6 +174,27 @@ describe('useIsMutating', () => {
172
174
  })
173
175
 
174
176
  describe('useMutationState', () => {
177
+ describe('types', () => {
178
+ it('should default to QueryState', () => {
179
+ doNotExecute(() => {
180
+ const result = useMutationState({
181
+ filters: { status: 'pending' },
182
+ })
183
+
184
+ expectTypeOf(result).toEqualTypeOf<Array<MutationState>>()
185
+ })
186
+ })
187
+ it('should infer with select', () => {
188
+ doNotExecute(() => {
189
+ const result = useMutationState({
190
+ filters: { status: 'pending' },
191
+ select: (mutation) => mutation.state.status,
192
+ })
193
+
194
+ expectTypeOf(result).toEqualTypeOf<Array<MutationStatus>>()
195
+ })
196
+ })
197
+ })
175
198
  it('should return variables after calling mutate', async () => {
176
199
  const queryClient = createQueryClient()
177
200
  const variables: unknown[][] = []