@tanstack/react-query 5.0.0-alpha.9 → 5.0.0-alpha.90

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 (411) hide show
  1. package/build/codemods/remove-overloads/remove-overloads.js +59 -0
  2. package/build/codemods/remove-overloads/transformers/filter-aware-usage-transformer.js +153 -0
  3. package/build/codemods/remove-overloads/transformers/query-fn-aware-usage-transformer.js +188 -0
  4. package/build/codemods/remove-overloads/utils/index.js +124 -0
  5. package/build/codemods/remove-overloads/utils/unknown-usage-error.js +27 -0
  6. package/build/codemods/rename-hydrate/rename-hydrate.js +55 -0
  7. package/build/codemods/rename-properties/rename-properties.js +41 -0
  8. package/build/codemods/src/utils/index.js +205 -0
  9. package/build/codemods/src/v4/key-transformation.js +138 -0
  10. package/build/codemods/src/v4/replace-import-specifier.js +25 -0
  11. package/build/codemods/transformers/query-cache-transformer.js +116 -0
  12. package/build/codemods/transformers/query-client-transformer.js +48 -0
  13. package/build/codemods/transformers/use-query-like-transformer.js +32 -0
  14. package/build/codemods/utils/replacers/key-replacer.js +164 -0
  15. package/build/legacy/HydrationBoundary.cjs +60 -0
  16. package/build/legacy/HydrationBoundary.cjs.map +1 -0
  17. package/build/legacy/HydrationBoundary.d.cts +12 -0
  18. package/build/legacy/HydrationBoundary.d.ts +12 -0
  19. package/build/legacy/HydrationBoundary.js +26 -0
  20. package/build/legacy/HydrationBoundary.js.map +1 -0
  21. package/build/legacy/QueryClientProvider.cjs +71 -0
  22. package/build/legacy/QueryClientProvider.cjs.map +1 -0
  23. package/build/legacy/QueryClientProvider.d.cts +12 -0
  24. package/build/legacy/QueryClientProvider.d.ts +12 -0
  25. package/build/legacy/QueryClientProvider.js +35 -0
  26. package/build/legacy/QueryClientProvider.js.map +1 -0
  27. package/build/legacy/QueryErrorResetBoundary.cjs +66 -0
  28. package/build/legacy/QueryErrorResetBoundary.cjs.map +1 -0
  29. package/build/legacy/QueryErrorResetBoundary.d.cts +14 -0
  30. package/build/legacy/QueryErrorResetBoundary.d.ts +14 -0
  31. package/build/legacy/QueryErrorResetBoundary.js +31 -0
  32. package/build/legacy/QueryErrorResetBoundary.js.map +1 -0
  33. package/build/legacy/errorBoundaryUtils.cjs +67 -0
  34. package/build/legacy/errorBoundaryUtils.cjs.map +1 -0
  35. package/build/legacy/errorBoundaryUtils.d.cts +14 -0
  36. package/build/legacy/errorBoundaryUtils.d.ts +14 -0
  37. package/build/legacy/errorBoundaryUtils.js +31 -0
  38. package/build/legacy/errorBoundaryUtils.js.map +1 -0
  39. package/build/legacy/index.cjs +85 -0
  40. package/build/legacy/index.cjs.map +1 -0
  41. package/build/legacy/index.d.cts +17 -0
  42. package/build/legacy/index.d.ts +17 -0
  43. package/build/legacy/index.js +46 -0
  44. package/build/legacy/index.js.map +1 -0
  45. package/build/legacy/infiniteQueryOptions.cjs +33 -0
  46. package/build/legacy/infiniteQueryOptions.cjs.map +1 -0
  47. package/build/legacy/infiniteQueryOptions.d.cts +13 -0
  48. package/build/legacy/infiniteQueryOptions.d.ts +13 -0
  49. package/build/legacy/infiniteQueryOptions.js +8 -0
  50. package/build/legacy/infiniteQueryOptions.js.map +1 -0
  51. package/build/legacy/isRestoring.cjs +47 -0
  52. package/build/legacy/isRestoring.cjs.map +1 -0
  53. package/build/legacy/isRestoring.d.cts +6 -0
  54. package/build/legacy/isRestoring.d.ts +6 -0
  55. package/build/legacy/isRestoring.js +12 -0
  56. package/build/legacy/isRestoring.js.map +1 -0
  57. package/build/legacy/queryOptions.cjs +33 -0
  58. package/build/legacy/queryOptions.cjs.map +1 -0
  59. package/build/legacy/queryOptions.d.cts +13 -0
  60. package/build/legacy/queryOptions.d.ts +13 -0
  61. package/build/legacy/queryOptions.js +8 -0
  62. package/build/legacy/queryOptions.js.map +1 -0
  63. package/build/legacy/suspense.cjs +48 -0
  64. package/build/legacy/suspense.cjs.map +1 -0
  65. package/build/legacy/suspense.d.cts +10 -0
  66. package/build/legacy/suspense.d.ts +10 -0
  67. package/build/legacy/suspense.js +20 -0
  68. package/build/legacy/suspense.js.map +1 -0
  69. package/build/legacy/types.cjs +19 -0
  70. package/build/legacy/types.cjs.map +1 -0
  71. package/build/legacy/types.d.cts +34 -0
  72. package/build/legacy/types.d.ts +34 -0
  73. package/build/legacy/types.js +1 -0
  74. package/build/legacy/types.js.map +1 -0
  75. package/build/legacy/useBaseQuery.cjs +92 -0
  76. package/build/legacy/useBaseQuery.cjs.map +1 -0
  77. package/build/legacy/useBaseQuery.d.cts +92 -0
  78. package/build/legacy/useBaseQuery.d.ts +92 -0
  79. package/build/legacy/useBaseQuery.js +62 -0
  80. package/build/legacy/useBaseQuery.js.map +1 -0
  81. package/build/legacy/useInfiniteQuery.cjs +41 -0
  82. package/build/legacy/useInfiniteQuery.cjs.map +1 -0
  83. package/build/legacy/useInfiniteQuery.d.cts +8 -0
  84. package/build/legacy/useInfiniteQuery.d.ts +8 -0
  85. package/build/legacy/useInfiniteQuery.js +17 -0
  86. package/build/legacy/useInfiniteQuery.js.map +1 -0
  87. package/build/legacy/useIsFetching.cjs +56 -0
  88. package/build/legacy/useIsFetching.cjs.map +1 -0
  89. package/build/legacy/useIsFetching.d.cts +5 -0
  90. package/build/legacy/useIsFetching.d.ts +5 -0
  91. package/build/legacy/useIsFetching.js +22 -0
  92. package/build/legacy/useIsFetching.js.map +1 -0
  93. package/build/legacy/useMutation.cjs +77 -0
  94. package/build/legacy/useMutation.cjs.map +1 -0
  95. package/build/legacy/useMutation.d.cts +6 -0
  96. package/build/legacy/useMutation.d.ts +6 -0
  97. package/build/legacy/useMutation.js +43 -0
  98. package/build/legacy/useMutation.js.map +1 -0
  99. package/build/legacy/useMutationState.cjs +88 -0
  100. package/build/legacy/useMutationState.cjs.map +1 -0
  101. package/build/legacy/useMutationState.d.cts +10 -0
  102. package/build/legacy/useMutationState.d.ts +10 -0
  103. package/build/legacy/useMutationState.js +53 -0
  104. package/build/legacy/useMutationState.js.map +1 -0
  105. package/build/legacy/useQueries.cjs +128 -0
  106. package/build/legacy/useQueries.cjs.map +1 -0
  107. package/build/legacy/useQueries.d.cts +53 -0
  108. package/build/{lib → legacy}/useQueries.d.ts +14 -11
  109. package/build/legacy/useQueries.js +103 -0
  110. package/build/legacy/useQueries.js.map +1 -0
  111. package/build/legacy/useQuery.cjs +36 -0
  112. package/build/legacy/useQuery.cjs.map +1 -0
  113. package/build/legacy/useQuery.d.cts +8 -0
  114. package/build/legacy/useQuery.d.ts +8 -0
  115. package/build/legacy/useQuery.js +12 -0
  116. package/build/legacy/useQuery.js.map +1 -0
  117. package/build/legacy/useSuspenseInfiniteQuery.cjs +46 -0
  118. package/build/legacy/useSuspenseInfiniteQuery.cjs.map +1 -0
  119. package/build/legacy/useSuspenseInfiniteQuery.d.cts +6 -0
  120. package/build/legacy/useSuspenseInfiniteQuery.d.ts +6 -0
  121. package/build/legacy/useSuspenseInfiniteQuery.js +22 -0
  122. package/build/legacy/useSuspenseInfiniteQuery.js.map +1 -0
  123. package/build/legacy/useSuspenseQuery.cjs +45 -0
  124. package/build/legacy/useSuspenseQuery.cjs.map +1 -0
  125. package/build/legacy/useSuspenseQuery.d.cts +6 -0
  126. package/build/legacy/useSuspenseQuery.d.ts +6 -0
  127. package/build/legacy/useSuspenseQuery.js +21 -0
  128. package/build/legacy/useSuspenseQuery.js.map +1 -0
  129. package/build/legacy/utils.cjs +36 -0
  130. package/build/legacy/utils.cjs.map +1 -0
  131. package/build/legacy/utils.d.cts +3 -0
  132. package/build/legacy/utils.d.ts +3 -0
  133. package/build/legacy/utils.js +11 -0
  134. package/build/legacy/utils.js.map +1 -0
  135. package/build/modern/HydrationBoundary.cjs +60 -0
  136. package/build/modern/HydrationBoundary.cjs.map +1 -0
  137. package/build/modern/HydrationBoundary.d.cts +12 -0
  138. package/build/modern/HydrationBoundary.d.ts +12 -0
  139. package/build/modern/HydrationBoundary.js +26 -0
  140. package/build/modern/HydrationBoundary.js.map +1 -0
  141. package/build/modern/QueryClientProvider.cjs +71 -0
  142. package/build/modern/QueryClientProvider.cjs.map +1 -0
  143. package/build/modern/QueryClientProvider.d.cts +12 -0
  144. package/build/modern/QueryClientProvider.d.ts +12 -0
  145. package/build/modern/QueryClientProvider.js +35 -0
  146. package/build/modern/QueryClientProvider.js.map +1 -0
  147. package/build/modern/QueryErrorResetBoundary.cjs +66 -0
  148. package/build/modern/QueryErrorResetBoundary.cjs.map +1 -0
  149. package/build/modern/QueryErrorResetBoundary.d.cts +14 -0
  150. package/build/modern/QueryErrorResetBoundary.d.ts +14 -0
  151. package/build/modern/QueryErrorResetBoundary.js +31 -0
  152. package/build/modern/QueryErrorResetBoundary.js.map +1 -0
  153. package/build/modern/errorBoundaryUtils.cjs +67 -0
  154. package/build/modern/errorBoundaryUtils.cjs.map +1 -0
  155. package/build/modern/errorBoundaryUtils.d.cts +14 -0
  156. package/build/modern/errorBoundaryUtils.d.ts +14 -0
  157. package/build/modern/errorBoundaryUtils.js +31 -0
  158. package/build/modern/errorBoundaryUtils.js.map +1 -0
  159. package/build/modern/index.cjs +85 -0
  160. package/build/modern/index.cjs.map +1 -0
  161. package/build/modern/index.d.cts +17 -0
  162. package/build/modern/index.d.ts +17 -0
  163. package/build/modern/index.js +46 -0
  164. package/build/modern/index.js.map +1 -0
  165. package/build/modern/infiniteQueryOptions.cjs +33 -0
  166. package/build/modern/infiniteQueryOptions.cjs.map +1 -0
  167. package/build/modern/infiniteQueryOptions.d.cts +13 -0
  168. package/build/modern/infiniteQueryOptions.d.ts +13 -0
  169. package/build/modern/infiniteQueryOptions.js +8 -0
  170. package/build/modern/infiniteQueryOptions.js.map +1 -0
  171. package/build/modern/isRestoring.cjs +47 -0
  172. package/build/modern/isRestoring.cjs.map +1 -0
  173. package/build/modern/isRestoring.d.cts +6 -0
  174. package/build/modern/isRestoring.d.ts +6 -0
  175. package/build/modern/isRestoring.js +12 -0
  176. package/build/modern/isRestoring.js.map +1 -0
  177. package/build/modern/queryOptions.cjs +33 -0
  178. package/build/modern/queryOptions.cjs.map +1 -0
  179. package/build/modern/queryOptions.d.cts +13 -0
  180. package/build/modern/queryOptions.d.ts +13 -0
  181. package/build/modern/queryOptions.js +8 -0
  182. package/build/modern/queryOptions.js.map +1 -0
  183. package/build/modern/suspense.cjs +48 -0
  184. package/build/modern/suspense.cjs.map +1 -0
  185. package/build/modern/suspense.d.cts +10 -0
  186. package/build/modern/suspense.d.ts +10 -0
  187. package/build/modern/suspense.js +20 -0
  188. package/build/modern/suspense.js.map +1 -0
  189. package/build/modern/types.cjs +19 -0
  190. package/build/modern/types.cjs.map +1 -0
  191. package/build/modern/types.d.cts +34 -0
  192. package/build/modern/types.d.ts +34 -0
  193. package/build/modern/types.js +1 -0
  194. package/build/modern/types.js.map +1 -0
  195. package/build/modern/useBaseQuery.cjs +92 -0
  196. package/build/modern/useBaseQuery.cjs.map +1 -0
  197. package/build/modern/useBaseQuery.d.cts +92 -0
  198. package/build/modern/useBaseQuery.d.ts +92 -0
  199. package/build/modern/useBaseQuery.js +62 -0
  200. package/build/modern/useBaseQuery.js.map +1 -0
  201. package/build/modern/useInfiniteQuery.cjs +41 -0
  202. package/build/modern/useInfiniteQuery.cjs.map +1 -0
  203. package/build/modern/useInfiniteQuery.d.cts +8 -0
  204. package/build/modern/useInfiniteQuery.d.ts +8 -0
  205. package/build/modern/useInfiniteQuery.js +17 -0
  206. package/build/modern/useInfiniteQuery.js.map +1 -0
  207. package/build/modern/useIsFetching.cjs +56 -0
  208. package/build/modern/useIsFetching.cjs.map +1 -0
  209. package/build/modern/useIsFetching.d.cts +5 -0
  210. package/build/modern/useIsFetching.d.ts +5 -0
  211. package/build/modern/useIsFetching.js +22 -0
  212. package/build/modern/useIsFetching.js.map +1 -0
  213. package/build/modern/useMutation.cjs +77 -0
  214. package/build/modern/useMutation.cjs.map +1 -0
  215. package/build/modern/useMutation.d.cts +6 -0
  216. package/build/modern/useMutation.d.ts +6 -0
  217. package/build/modern/useMutation.js +43 -0
  218. package/build/modern/useMutation.js.map +1 -0
  219. package/build/modern/useMutationState.cjs +88 -0
  220. package/build/modern/useMutationState.cjs.map +1 -0
  221. package/build/modern/useMutationState.d.cts +10 -0
  222. package/build/modern/useMutationState.d.ts +10 -0
  223. package/build/modern/useMutationState.js +53 -0
  224. package/build/modern/useMutationState.js.map +1 -0
  225. package/build/modern/useQueries.cjs +125 -0
  226. package/build/modern/useQueries.cjs.map +1 -0
  227. package/build/modern/useQueries.d.cts +53 -0
  228. package/build/modern/useQueries.d.ts +53 -0
  229. package/build/modern/useQueries.js +100 -0
  230. package/build/modern/useQueries.js.map +1 -0
  231. package/build/modern/useQuery.cjs +36 -0
  232. package/build/modern/useQuery.cjs.map +1 -0
  233. package/build/modern/useQuery.d.cts +8 -0
  234. package/build/modern/useQuery.d.ts +8 -0
  235. package/build/modern/useQuery.js +12 -0
  236. package/build/modern/useQuery.js.map +1 -0
  237. package/build/modern/useSuspenseInfiniteQuery.cjs +46 -0
  238. package/build/modern/useSuspenseInfiniteQuery.cjs.map +1 -0
  239. package/build/modern/useSuspenseInfiniteQuery.d.cts +6 -0
  240. package/build/modern/useSuspenseInfiniteQuery.d.ts +6 -0
  241. package/build/modern/useSuspenseInfiniteQuery.js +22 -0
  242. package/build/modern/useSuspenseInfiniteQuery.js.map +1 -0
  243. package/build/modern/useSuspenseQuery.cjs +45 -0
  244. package/build/modern/useSuspenseQuery.cjs.map +1 -0
  245. package/build/modern/useSuspenseQuery.d.cts +6 -0
  246. package/build/modern/useSuspenseQuery.d.ts +6 -0
  247. package/build/modern/useSuspenseQuery.js +21 -0
  248. package/build/modern/useSuspenseQuery.js.map +1 -0
  249. package/build/modern/utils.cjs +36 -0
  250. package/build/modern/utils.cjs.map +1 -0
  251. package/build/modern/utils.d.cts +3 -0
  252. package/build/modern/utils.d.ts +3 -0
  253. package/build/modern/utils.js +11 -0
  254. package/build/modern/utils.js.map +1 -0
  255. package/package.json +29 -17
  256. package/src/HydrationBoundary.tsx +1 -1
  257. package/src/__tests__/HydrationBoundary.test.tsx +5 -5
  258. package/src/__tests__/QueryClientProvider.test.tsx +2 -2
  259. package/src/__tests__/QueryResetErrorBoundary.test.tsx +753 -621
  260. package/src/__tests__/ssr-hydration.test.tsx +4 -4
  261. package/src/__tests__/ssr.test.tsx +2 -2
  262. package/src/__tests__/suspense.test.tsx +8 -90
  263. package/src/__tests__/useInfiniteQuery.test.tsx +36 -74
  264. package/src/__tests__/useInfiniteQuery.type.test.tsx +2 -29
  265. package/src/__tests__/useIsFetching.test.tsx +1 -1
  266. package/src/__tests__/useMutation.test.tsx +22 -23
  267. package/src/__tests__/useMutationState.test.tsx +23 -0
  268. package/src/__tests__/useQueries.test.tsx +214 -91
  269. package/src/__tests__/useQuery.test.tsx +431 -453
  270. package/src/__tests__/useQuery.types.test.tsx +22 -1
  271. package/src/__tests__/utils.tsx +11 -5
  272. package/src/errorBoundaryUtils.ts +7 -7
  273. package/src/index.ts +4 -0
  274. package/src/infiniteQueryOptions.ts +93 -0
  275. package/src/queryOptions.ts +42 -0
  276. package/src/suspense.ts +9 -15
  277. package/src/types.ts +50 -8
  278. package/src/useBaseQuery.ts +14 -26
  279. package/src/useInfiniteQuery.ts +50 -7
  280. package/src/useIsFetching.ts +1 -1
  281. package/src/useMutation.ts +4 -4
  282. package/src/useMutationState.ts +8 -8
  283. package/src/useQueries.ts +53 -36
  284. package/src/useQuery.ts +6 -21
  285. package/src/useSuspenseInfiniteQuery.ts +47 -0
  286. package/src/useSuspenseQuery.ts +26 -0
  287. package/build/lib/HydrationBoundary.d.ts +0 -9
  288. package/build/lib/HydrationBoundary.esm.js +0 -29
  289. package/build/lib/HydrationBoundary.esm.js.map +0 -1
  290. package/build/lib/HydrationBoundary.js +0 -50
  291. package/build/lib/HydrationBoundary.js.map +0 -1
  292. package/build/lib/HydrationBoundary.mjs +0 -29
  293. package/build/lib/HydrationBoundary.mjs.map +0 -1
  294. package/build/lib/QueryClientProvider.d.ts +0 -9
  295. package/build/lib/QueryClientProvider.esm.js +0 -31
  296. package/build/lib/QueryClientProvider.esm.js.map +0 -1
  297. package/build/lib/QueryClientProvider.js +0 -54
  298. package/build/lib/QueryClientProvider.js.map +0 -1
  299. package/build/lib/QueryClientProvider.mjs +0 -31
  300. package/build/lib/QueryClientProvider.mjs.map +0 -1
  301. package/build/lib/QueryErrorResetBoundary.d.ts +0 -11
  302. package/build/lib/QueryErrorResetBoundary.esm.js +0 -38
  303. package/build/lib/QueryErrorResetBoundary.esm.js.map +0 -1
  304. package/build/lib/QueryErrorResetBoundary.js +0 -60
  305. package/build/lib/QueryErrorResetBoundary.js.map +0 -1
  306. package/build/lib/QueryErrorResetBoundary.mjs +0 -38
  307. package/build/lib/QueryErrorResetBoundary.mjs.map +0 -1
  308. package/build/lib/__tests__/HydrationBoundary.test.d.ts +0 -1
  309. package/build/lib/__tests__/QueryClientProvider.test.d.ts +0 -1
  310. package/build/lib/__tests__/QueryResetErrorBoundary.test.d.ts +0 -6
  311. package/build/lib/__tests__/ssr-hydration.test.d.ts +0 -1
  312. package/build/lib/__tests__/ssr.test.d.ts +0 -1
  313. package/build/lib/__tests__/suspense.test.d.ts +0 -1
  314. package/build/lib/__tests__/useInfiniteQuery.test.d.ts +0 -1
  315. package/build/lib/__tests__/useInfiniteQuery.type.test.d.ts +0 -1
  316. package/build/lib/__tests__/useIsFetching.test.d.ts +0 -1
  317. package/build/lib/__tests__/useMutation.test.d.ts +0 -1
  318. package/build/lib/__tests__/useMutationState.test.d.ts +0 -1
  319. package/build/lib/__tests__/useQueries.test.d.ts +0 -1
  320. package/build/lib/__tests__/useQuery.test.d.ts +0 -1
  321. package/build/lib/__tests__/useQuery.types.test.d.ts +0 -1
  322. package/build/lib/__tests__/utils.d.ts +0 -28
  323. package/build/lib/errorBoundaryUtils.d.ts +0 -10
  324. package/build/lib/errorBoundaryUtils.esm.js +0 -28
  325. package/build/lib/errorBoundaryUtils.esm.js.map +0 -1
  326. package/build/lib/errorBoundaryUtils.js +0 -51
  327. package/build/lib/errorBoundaryUtils.js.map +0 -1
  328. package/build/lib/errorBoundaryUtils.mjs +0 -28
  329. package/build/lib/errorBoundaryUtils.mjs.map +0 -1
  330. package/build/lib/index.d.ts +0 -16
  331. package/build/lib/index.esm.js +0 -12
  332. package/build/lib/index.esm.js.map +0 -1
  333. package/build/lib/index.js +0 -38
  334. package/build/lib/index.js.map +0 -1
  335. package/build/lib/index.mjs +0 -12
  336. package/build/lib/index.mjs.map +0 -1
  337. package/build/lib/isRestoring.d.ts +0 -3
  338. package/build/lib/isRestoring.esm.js +0 -9
  339. package/build/lib/isRestoring.esm.js.map +0 -1
  340. package/build/lib/isRestoring.js +0 -31
  341. package/build/lib/isRestoring.js.map +0 -1
  342. package/build/lib/isRestoring.mjs +0 -9
  343. package/build/lib/isRestoring.mjs.map +0 -1
  344. package/build/lib/suspense.d.ts +0 -9
  345. package/build/lib/suspense.esm.js +0 -24
  346. package/build/lib/suspense.esm.js.map +0 -1
  347. package/build/lib/suspense.js +0 -29
  348. package/build/lib/suspense.js.map +0 -1
  349. package/build/lib/suspense.mjs +0 -24
  350. package/build/lib/suspense.mjs.map +0 -1
  351. package/build/lib/types.d.ts +0 -26
  352. package/build/lib/useBaseQuery.d.ts +0 -3
  353. package/build/lib/useBaseQuery.esm.js +0 -63
  354. package/build/lib/useBaseQuery.esm.js.map +0 -1
  355. package/build/lib/useBaseQuery.js +0 -84
  356. package/build/lib/useBaseQuery.js.map +0 -1
  357. package/build/lib/useBaseQuery.mjs +0 -63
  358. package/build/lib/useBaseQuery.mjs.map +0 -1
  359. package/build/lib/useInfiniteQuery.d.ts +0 -3
  360. package/build/lib/useInfiniteQuery.esm.js +0 -13
  361. package/build/lib/useInfiniteQuery.esm.js.map +0 -1
  362. package/build/lib/useInfiniteQuery.js +0 -15
  363. package/build/lib/useInfiniteQuery.js.map +0 -1
  364. package/build/lib/useInfiniteQuery.mjs +0 -13
  365. package/build/lib/useInfiniteQuery.mjs.map +0 -1
  366. package/build/lib/useIsFetching.d.ts +0 -2
  367. package/build/lib/useIsFetching.esm.js +0 -13
  368. package/build/lib/useIsFetching.esm.js.map +0 -1
  369. package/build/lib/useIsFetching.js +0 -34
  370. package/build/lib/useIsFetching.js.map +0 -1
  371. package/build/lib/useIsFetching.mjs +0 -13
  372. package/build/lib/useIsFetching.mjs.map +0 -1
  373. package/build/lib/useMutation.d.ts +0 -3
  374. package/build/lib/useMutation.esm.js +0 -33
  375. package/build/lib/useMutation.esm.js.map +0 -1
  376. package/build/lib/useMutation.js +0 -54
  377. package/build/lib/useMutation.js.map +0 -1
  378. package/build/lib/useMutation.mjs +0 -33
  379. package/build/lib/useMutation.mjs.map +0 -1
  380. package/build/lib/useMutationState.d.ts +0 -8
  381. package/build/lib/useMutationState.esm.js +0 -38
  382. package/build/lib/useMutationState.esm.js.map +0 -1
  383. package/build/lib/useMutationState.js +0 -60
  384. package/build/lib/useMutationState.js.map +0 -1
  385. package/build/lib/useMutationState.mjs +0 -38
  386. package/build/lib/useMutationState.mjs.map +0 -1
  387. package/build/lib/useQueries.esm.js +0 -73
  388. package/build/lib/useQueries.esm.js.map +0 -1
  389. package/build/lib/useQueries.js +0 -94
  390. package/build/lib/useQueries.js.map +0 -1
  391. package/build/lib/useQueries.mjs +0 -70
  392. package/build/lib/useQueries.mjs.map +0 -1
  393. package/build/lib/useQuery.d.ts +0 -11
  394. package/build/lib/useQuery.esm.js +0 -12
  395. package/build/lib/useQuery.esm.js.map +0 -1
  396. package/build/lib/useQuery.js +0 -14
  397. package/build/lib/useQuery.js.map +0 -1
  398. package/build/lib/useQuery.mjs +0 -12
  399. package/build/lib/useQuery.mjs.map +0 -1
  400. package/build/lib/utils.d.ts +0 -1
  401. package/build/lib/utils.esm.js +0 -10
  402. package/build/lib/utils.esm.js.map +0 -1
  403. package/build/lib/utils.js +0 -12
  404. package/build/lib/utils.js.map +0 -1
  405. package/build/lib/utils.mjs +0 -10
  406. package/build/lib/utils.mjs.map +0 -1
  407. package/build/umd/index.development.js +0 -3040
  408. package/build/umd/index.development.js.map +0 -1
  409. package/build/umd/index.production.js +0 -2
  410. package/build/umd/index.production.js.map +0 -1
  411. /package/src/{isRestoring.tsx → isRestoring.ts} +0 -0
@@ -1,17 +1,17 @@
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'
8
8
 
9
9
  import {
10
- useQuery,
11
- QueryClientProvider,
12
10
  QueryCache,
11
+ QueryClientProvider,
13
12
  dehydrate,
14
13
  hydrate,
14
+ useQuery,
15
15
  } from '..'
16
16
  import { createQueryClient, setIsServer, sleep } from './utils'
17
17
 
@@ -2,9 +2,9 @@ import * as React from 'react'
2
2
  // @ts-ignore
3
3
  import { renderToString } from 'react-dom/server'
4
4
 
5
- import { sleep, queryKey, createQueryClient } from './utils'
6
- import { useQuery, QueryClientProvider, QueryCache, useInfiniteQuery } from '..'
7
5
  import { vi } from 'vitest'
6
+ import { QueryCache, QueryClientProvider, useInfiniteQuery, useQuery } from '..'
7
+ import { createQueryClient, queryKey, sleep } from './utils'
8
8
 
9
9
  describe('Server Side Rendering', () => {
10
10
  it('should not trigger fetch', () => {
@@ -1,7 +1,7 @@
1
1
  import { fireEvent, waitFor } from '@testing-library/react'
2
2
  import * as React from 'react'
3
3
  import { ErrorBoundary } from 'react-error-boundary'
4
- import type { InfiniteData, UseInfiniteQueryResult, UseQueryResult } from '..'
4
+ import { vi } from 'vitest'
5
5
  import {
6
6
  QueryCache,
7
7
  QueryErrorResetBoundary,
@@ -11,7 +11,7 @@ import {
11
11
  useQueryErrorResetBoundary,
12
12
  } from '..'
13
13
  import { createQueryClient, queryKey, renderWithClient, sleep } from './utils'
14
- import { vi } from 'vitest'
14
+ import type { InfiniteData, UseInfiniteQueryResult, UseQueryResult } from '..'
15
15
 
16
16
  describe("useQuery's in Suspense mode", () => {
17
17
  const queryCache = new QueryCache()
@@ -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
  }
@@ -1,6 +1,8 @@
1
1
  import { fireEvent, render, waitFor } from '@testing-library/react'
2
2
  import * as React from 'react'
3
3
 
4
+ import { vi } from 'vitest'
5
+ import { QueryCache, keepPreviousData, useInfiniteQuery } from '..'
4
6
  import {
5
7
  createQueryClient,
6
8
  queryKey,
@@ -13,8 +15,6 @@ import type {
13
15
  QueryFunctionContext,
14
16
  UseInfiniteQueryResult,
15
17
  } from '..'
16
- import { QueryCache, useInfiniteQuery, keepPreviousData } from '..'
17
- import { vi } from 'vitest'
18
18
  import type { Mock } from 'vitest'
19
19
 
20
20
  interface Result {
@@ -213,7 +213,7 @@ describe('useInfiniteQuery', () => {
213
213
 
214
214
  await waitFor(() => rendered.getByText('data: 0-asc'))
215
215
  await waitFor(() => rendered.getByText('isFetching: false'))
216
- await waitFor(() => expect(states.length).toBe(7))
216
+ await waitFor(() => expect(states.length).toBe(6))
217
217
 
218
218
  expect(states[0]).toMatchObject({
219
219
  data: undefined,
@@ -251,15 +251,7 @@ describe('useInfiniteQuery', () => {
251
251
  isSuccess: true,
252
252
  isPlaceholderData: true,
253
253
  })
254
- // Hook state update
255
254
  expect(states[5]).toMatchObject({
256
- data: { pages: ['0-desc', '1-desc'] },
257
- isFetching: true,
258
- isFetchingNextPage: false,
259
- isSuccess: true,
260
- isPlaceholderData: true,
261
- })
262
- expect(states[6]).toMatchObject({
263
255
  data: { pages: ['0-asc'] },
264
256
  isFetching: false,
265
257
  isFetchingNextPage: false,
@@ -606,77 +598,47 @@ describe('useInfiniteQuery', () => {
606
598
 
607
599
  it('should silently cancel any ongoing fetch when fetching more', async () => {
608
600
  const key = queryKey()
609
- const states: UseInfiniteQueryResult<InfiniteData<number>>[] = []
610
601
 
611
602
  function Page() {
612
603
  const start = 10
613
- const state = useInfiniteQuery({
614
- queryKey: key,
615
- queryFn: async ({ pageParam }) => {
616
- await sleep(50)
617
- return Number(pageParam)
618
- },
619
- defaultPageParam: start,
620
- getNextPageParam: (lastPage) => lastPage + 1,
621
- notifyOnChangeProps: 'all',
622
- })
623
-
624
- states.push(state)
625
-
626
- const { refetch, fetchNextPage } = state
627
-
628
- React.useEffect(() => {
629
- setActTimeout(() => {
630
- refetch()
631
- }, 100)
632
- setActTimeout(() => {
633
- fetchNextPage()
634
- }, 110)
635
- }, [fetchNextPage, refetch])
604
+ const { data, fetchNextPage, refetch, status, fetchStatus } =
605
+ useInfiniteQuery({
606
+ queryKey: key,
607
+ queryFn: async ({ pageParam }) => {
608
+ await sleep(50)
609
+ return Number(pageParam)
610
+ },
611
+ defaultPageParam: start,
612
+ getNextPageParam: (lastPage) => lastPage + 1,
613
+ })
636
614
 
637
- return null
615
+ return (
616
+ <div>
617
+ <button onClick={() => fetchNextPage()}>fetchNextPage</button>
618
+ <button onClick={() => refetch()}>refetch</button>
619
+ <div>data: {JSON.stringify(data)}</div>
620
+ <div>
621
+ status: {status}, {fetchStatus}
622
+ </div>
623
+ </div>
624
+ )
638
625
  }
639
626
 
640
- renderWithClient(queryClient, <Page />)
627
+ const rendered = renderWithClient(queryClient, <Page />)
641
628
 
642
- await sleep(300)
629
+ await waitFor(() => rendered.getByText('status: success, idle'))
630
+ await waitFor(() =>
631
+ rendered.getByText('data: {"pages":[10],"pageParams":[10]}'),
632
+ )
643
633
 
644
- expect(states.length).toBe(5)
645
- expect(states[0]).toMatchObject({
646
- hasNextPage: false,
647
- data: undefined,
648
- isFetching: true,
649
- isFetchingNextPage: false,
650
- isSuccess: false,
651
- })
652
- expect(states[1]).toMatchObject({
653
- hasNextPage: true,
654
- data: { pages: [10] },
655
- isFetching: false,
656
- isFetchingNextPage: false,
657
- isSuccess: true,
658
- })
659
- expect(states[2]).toMatchObject({
660
- hasNextPage: true,
661
- data: { pages: [10] },
662
- isFetching: true,
663
- isFetchingNextPage: false,
664
- isSuccess: true,
665
- })
666
- expect(states[3]).toMatchObject({
667
- hasNextPage: true,
668
- data: { pages: [10] },
669
- isFetching: true,
670
- isFetchingNextPage: true,
671
- isSuccess: true,
672
- })
673
- expect(states[4]).toMatchObject({
674
- hasNextPage: true,
675
- data: { pages: [10, 11] },
676
- isFetching: false,
677
- isFetchingNextPage: false,
678
- isSuccess: true,
679
- })
634
+ fireEvent.click(rendered.getByRole('button', { name: /refetch/i }))
635
+ await waitFor(() => rendered.getByText('status: success, fetching'))
636
+ fireEvent.click(rendered.getByRole('button', { name: /fetchNextPage/i }))
637
+
638
+ await waitFor(() => rendered.getByText('status: success, idle'))
639
+ await waitFor(() =>
640
+ rendered.getByText('data: {"pages":[10,11],"pageParams":[10,11]}'),
641
+ )
680
642
  })
681
643
 
682
644
  it('should silently cancel an ongoing fetchNextPage request when another fetchNextPage is invoked', async () => {
@@ -1,9 +1,9 @@
1
- import type { InfiniteData } from '@tanstack/query-core'
2
1
  import { QueryClient } from '@tanstack/query-core'
3
2
  import { useInfiniteQuery } from '../useInfiniteQuery'
4
3
  import { useQuery } from '../useQuery'
5
- import type { Expect, Equal } from './utils'
6
4
  import { doNotExecute } from './utils'
5
+ import type { Equal, Expect } from './utils'
6
+ import type { InfiniteData } from '@tanstack/query-core'
7
7
 
8
8
  describe('pageParam', () => {
9
9
  it('defaultPageParam should define type of param passed to queryFunctionContext', () => {
@@ -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', () => {
@@ -1,6 +1,7 @@
1
1
  import { fireEvent, render, waitFor } from '@testing-library/react'
2
2
  import * as React from 'react'
3
3
 
4
+ import { QueryCache, useIsFetching, useQuery } from '..'
4
5
  import {
5
6
  createQueryClient,
6
7
  queryKey,
@@ -8,7 +9,6 @@ import {
8
9
  setActTimeout,
9
10
  sleep,
10
11
  } from './utils'
11
- import { QueryCache, useIsFetching, useQuery } from '..'
12
12
 
13
13
  describe('useIsFetching', () => {
14
14
  // See https://github.com/tannerlinsley/react-query/issues/105
@@ -3,17 +3,17 @@ import '@testing-library/jest-dom'
3
3
  import * as React from 'react'
4
4
  import { ErrorBoundary } from 'react-error-boundary'
5
5
 
6
+ import { vi } from 'vitest'
6
7
  import { MutationCache, QueryCache, useMutation } from '..'
7
- import type { UseMutationResult } from '../types'
8
8
  import {
9
9
  createQueryClient,
10
- mockNavigatorOnLine,
10
+ mockOnlineManagerIsOnline,
11
11
  queryKey,
12
12
  renderWithClient,
13
13
  setActTimeout,
14
14
  sleep,
15
15
  } from './utils'
16
- import { vi } from 'vitest'
16
+ import type { UseMutationResult } from '../types'
17
17
 
18
18
  describe('useMutation', () => {
19
19
  const queryCache = new QueryCache()
@@ -427,7 +427,7 @@ describe('useMutation', () => {
427
427
  })
428
428
 
429
429
  it('should not retry mutations while offline', async () => {
430
- const onlineMock = mockNavigatorOnLine(false)
430
+ const onlineMock = mockOnlineManagerIsOnline(false)
431
431
 
432
432
  let count = 0
433
433
 
@@ -455,6 +455,8 @@ describe('useMutation', () => {
455
455
 
456
456
  const rendered = renderWithClient(queryClient, <Page />)
457
457
 
458
+ window.dispatchEvent(new Event('offline'))
459
+
458
460
  await waitFor(() => {
459
461
  expect(
460
462
  rendered.getByText('error: null, status: idle, isPaused: false'),
@@ -471,7 +473,7 @@ describe('useMutation', () => {
471
473
 
472
474
  expect(count).toBe(0)
473
475
 
474
- onlineMock.mockReturnValue(true)
476
+ onlineMock.mockRestore()
475
477
  window.dispatchEvent(new Event('online'))
476
478
 
477
479
  await sleep(100)
@@ -483,12 +485,10 @@ describe('useMutation', () => {
483
485
  })
484
486
 
485
487
  expect(count).toBe(2)
486
-
487
- onlineMock.mockRestore()
488
488
  })
489
489
 
490
490
  it('should call onMutate even if paused', async () => {
491
- const onlineMock = mockNavigatorOnLine(false)
491
+ const onlineMock = mockOnlineManagerIsOnline(false)
492
492
  const onMutate = vi.fn()
493
493
  let count = 0
494
494
 
@@ -517,6 +517,8 @@ describe('useMutation', () => {
517
517
 
518
518
  await rendered.findByText('data: null, status: idle, isPaused: false')
519
519
 
520
+ window.dispatchEvent(new Event('offline'))
521
+
520
522
  fireEvent.click(rendered.getByRole('button', { name: /mutate/i }))
521
523
 
522
524
  await rendered.findByText('data: null, status: pending, isPaused: true')
@@ -524,19 +526,17 @@ describe('useMutation', () => {
524
526
  expect(onMutate).toHaveBeenCalledTimes(1)
525
527
  expect(onMutate).toHaveBeenCalledWith('todo')
526
528
 
527
- onlineMock.mockReturnValue(true)
529
+ onlineMock.mockRestore()
528
530
  window.dispatchEvent(new Event('online'))
529
531
 
530
532
  await rendered.findByText('data: 1, status: success, isPaused: false')
531
533
 
532
534
  expect(onMutate).toHaveBeenCalledTimes(1)
533
535
  expect(count).toBe(1)
534
-
535
- onlineMock.mockRestore()
536
536
  })
537
537
 
538
538
  it('should optimistically go to paused state if offline', async () => {
539
- const onlineMock = mockNavigatorOnLine(false)
539
+ const onlineMock = mockOnlineManagerIsOnline(false)
540
540
  let count = 0
541
541
  const states: Array<string> = []
542
542
 
@@ -566,6 +566,8 @@ describe('useMutation', () => {
566
566
 
567
567
  await rendered.findByText('data: null, status: idle, isPaused: false')
568
568
 
569
+ window.dispatchEvent(new Event('offline'))
570
+
569
571
  fireEvent.click(rendered.getByRole('button', { name: /mutate/i }))
570
572
 
571
573
  await rendered.findByText('data: null, status: pending, isPaused: true')
@@ -574,16 +576,14 @@ describe('useMutation', () => {
574
576
  expect(states[0]).toBe('idle, false')
575
577
  expect(states[1]).toBe('pending, true')
576
578
 
577
- onlineMock.mockReturnValue(true)
579
+ onlineMock.mockRestore()
578
580
  window.dispatchEvent(new Event('online'))
579
581
 
580
582
  await rendered.findByText('data: 1, status: success, isPaused: false')
581
-
582
- onlineMock.mockRestore()
583
583
  })
584
584
 
585
585
  it('should be able to retry a mutation when online', async () => {
586
- const onlineMock = mockNavigatorOnLine(false)
586
+ const onlineMock = mockOnlineManagerIsOnline(false)
587
587
 
588
588
  let count = 0
589
589
  const states: UseMutationResult<any, any, any, any>[] = []
@@ -608,6 +608,7 @@ describe('useMutation', () => {
608
608
 
609
609
  React.useEffect(() => {
610
610
  setActTimeout(() => {
611
+ window.dispatchEvent(new Event('offline'))
611
612
  mutate('todo')
612
613
  }, 10)
613
614
  }, [mutate])
@@ -645,7 +646,7 @@ describe('useMutation', () => {
645
646
  failureReason: new Error('oops'),
646
647
  })
647
648
 
648
- onlineMock.mockReturnValue(true)
649
+ onlineMock.mockRestore()
649
650
  window.dispatchEvent(new Event('online'))
650
651
 
651
652
  await sleep(50)
@@ -664,8 +665,6 @@ describe('useMutation', () => {
664
665
  failureReason: null,
665
666
  data: 'data',
666
667
  })
667
-
668
- onlineMock.mockRestore()
669
668
  })
670
669
 
671
670
  it('should not change state if unmounted', async () => {
@@ -688,7 +687,7 @@ describe('useMutation', () => {
688
687
  fireEvent.click(getByText('unmount'))
689
688
  })
690
689
 
691
- it('should be able to throw an error when throwErrors is set to true', async () => {
690
+ it('should be able to throw an error when throwOnError is set to true', async () => {
692
691
  const consoleMock = vi
693
692
  .spyOn(console, 'error')
694
693
  .mockImplementation(() => undefined)
@@ -699,7 +698,7 @@ describe('useMutation', () => {
699
698
  err.stack = ''
700
699
  return Promise.reject(err)
701
700
  },
702
- throwErrors: true,
701
+ throwOnError: true,
703
702
  })
704
703
 
705
704
  return (
@@ -735,7 +734,7 @@ describe('useMutation', () => {
735
734
  consoleMock.mockRestore()
736
735
  })
737
736
 
738
- it('should be able to throw an error when throwErrors is a function that returns true', async () => {
737
+ it('should be able to throw an error when throwOnError is a function that returns true', async () => {
739
738
  const consoleMock = vi
740
739
  .spyOn(console, 'error')
741
740
  .mockImplementation(() => undefined)
@@ -747,7 +746,7 @@ describe('useMutation', () => {
747
746
  err.stack = ''
748
747
  return Promise.reject(err)
749
748
  },
750
- throwErrors: () => {
749
+ throwOnError: () => {
751
750
  boundary = !boundary
752
751
  return !boundary
753
752
  },
@@ -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[][] = []