@tanstack/solid-query 5.0.0-alpha.6 → 5.0.0-alpha.62

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 (81) hide show
  1. package/{build/cjs/index.js → dist/cjs/index.cjs} +91 -31
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/{build → dist}/esm/index.js +91 -33
  4. package/dist/esm/index.js.map +1 -0
  5. package/dist/source/QueryClient.js +6 -0
  6. package/{build → dist}/source/createBaseQuery.js +49 -23
  7. package/{build → dist}/source/createMutation.js +1 -1
  8. package/{build → dist}/source/createQueries.js +13 -7
  9. package/{build → dist}/source/createQuery.js +3 -0
  10. package/{build → dist}/source/index.js +2 -1
  11. package/dist/types/QueryClient.d.ts +29 -0
  12. package/{build → dist}/types/QueryClientProvider.d.ts +3 -3
  13. package/{build → dist}/types/createBaseQuery.d.ts +2 -1
  14. package/{build → dist}/types/createInfiniteQuery.d.ts +2 -1
  15. package/{build → dist}/types/createMutation.d.ts +2 -1
  16. package/{build → dist}/types/createQueries.d.ts +11 -9
  17. package/dist/types/createQuery.d.ts +14 -0
  18. package/{build → dist}/types/index.d.ts +3 -1
  19. package/dist/types/types.d.ts +34 -0
  20. package/{build → dist}/types/useIsFetching.d.ts +2 -1
  21. package/{build → dist}/types/useIsMutating.d.ts +2 -1
  22. package/package.json +22 -26
  23. package/src/QueryClient.ts +84 -0
  24. package/src/QueryClientProvider.tsx +1 -1
  25. package/src/__tests__/QueryClientProvider.test.tsx +2 -3
  26. package/src/__tests__/createInfiniteQuery.test.tsx +83 -19
  27. package/src/__tests__/createMutation.test.tsx +5 -5
  28. package/src/__tests__/createQueries.test.tsx +6 -78
  29. package/src/__tests__/createQuery.test.tsx +66 -334
  30. package/src/__tests__/createQuery.types.test.tsx +21 -1
  31. package/src/__tests__/suspense.test.tsx +7 -90
  32. package/src/__tests__/transition.test.tsx +1 -1
  33. package/src/__tests__/useIsFetching.test.tsx +1 -1
  34. package/src/__tests__/useIsMutating.test.tsx +5 -7
  35. package/src/__tests__/utils.tsx +1 -1
  36. package/src/createBaseQuery.ts +73 -28
  37. package/src/createInfiniteQuery.ts +1 -1
  38. package/src/createMutation.ts +3 -2
  39. package/src/createQueries.ts +32 -14
  40. package/src/createQuery.ts +24 -1
  41. package/src/index.ts +8 -1
  42. package/src/types.ts +4 -2
  43. package/src/useIsFetching.ts +2 -1
  44. package/src/useIsMutating.ts +2 -1
  45. package/build/cjs/index.js.map +0 -1
  46. package/build/esm/index.js.map +0 -1
  47. package/build/source/__tests__/QueryClientProvider.test.jsx +0 -121
  48. package/build/source/__tests__/createInfiniteQuery.test.jsx +0 -1315
  49. package/build/source/__tests__/createMutation.test.jsx +0 -867
  50. package/build/source/__tests__/createQueries.test.jsx +0 -661
  51. package/build/source/__tests__/createQuery.test.jsx +0 -4608
  52. package/build/source/__tests__/createQuery.types.test.jsx +0 -135
  53. package/build/source/__tests__/suspense.test.jsx +0 -721
  54. package/build/source/__tests__/transition.test.jsx +0 -42
  55. package/build/source/__tests__/useIsFetching.test.jsx +0 -190
  56. package/build/source/__tests__/useIsMutating.test.jsx +0 -198
  57. package/build/source/__tests__/utils.jsx +0 -50
  58. package/build/types/__tests__/QueryClientProvider.test.d.ts +0 -1
  59. package/build/types/__tests__/createInfiniteQuery.test.d.ts +0 -1
  60. package/build/types/__tests__/createMutation.test.d.ts +0 -1
  61. package/build/types/__tests__/createQueries.test.d.ts +0 -1
  62. package/build/types/__tests__/createQuery.test.d.ts +0 -1
  63. package/build/types/__tests__/createQuery.types.test.d.ts +0 -2
  64. package/build/types/__tests__/suspense.test.d.ts +0 -1
  65. package/build/types/__tests__/transition.test.d.ts +0 -1
  66. package/build/types/__tests__/useIsFetching.test.d.ts +0 -1
  67. package/build/types/__tests__/useIsMutating.test.d.ts +0 -1
  68. package/build/types/__tests__/utils.d.ts +0 -21
  69. package/build/types/createQuery.d.ts +0 -11
  70. package/build/types/types.d.ts +0 -33
  71. package/build/umd/index.js +0 -2
  72. package/build/umd/index.js.map +0 -1
  73. /package/{build → dist}/source/QueryClientProvider.jsx +0 -0
  74. /package/{build → dist}/source/createInfiniteQuery.js +0 -0
  75. /package/{build → dist}/source/setBatchUpdatesFn.js +0 -0
  76. /package/{build → dist}/source/types.js +0 -0
  77. /package/{build → dist}/source/useIsFetching.js +0 -0
  78. /package/{build → dist}/source/useIsMutating.js +0 -0
  79. /package/{build → dist}/source/utils.js +0 -0
  80. /package/{build → dist}/types/setBatchUpdatesFn.d.ts +0 -0
  81. /package/{build → dist}/types/utils.d.ts +0 -0
@@ -0,0 +1,84 @@
1
+ import type {
2
+ QueryClientConfig as QueryCoreClientConfig,
3
+ DefaultOptions as CoreDefaultOptions,
4
+ QueryObserverOptions as QueryCoreObserverOptions,
5
+ InfiniteQueryObserverOptions as QueryCoreInfiniteQueryObserverOptions,
6
+ DefaultError,
7
+ QueryKey,
8
+ } from '@tanstack/query-core'
9
+ import { QueryClient as QueryCoreClient } from '@tanstack/query-core'
10
+
11
+ export interface QueryObserverOptions<
12
+ TQueryFnData = unknown,
13
+ TError = DefaultError,
14
+ TData = TQueryFnData,
15
+ TQueryData = TQueryFnData,
16
+ TQueryKey extends QueryKey = QueryKey,
17
+ TPageParam = never,
18
+ > extends Omit<
19
+ QueryCoreObserverOptions<
20
+ TQueryFnData,
21
+ TError,
22
+ TData,
23
+ TQueryData,
24
+ TQueryKey,
25
+ TPageParam
26
+ >,
27
+ 'structuralSharing'
28
+ > {
29
+ /**
30
+ * Set this to a reconciliation key to enable reconciliation between query results.
31
+ * Set this to `false` to disable reconciliation between query results.
32
+ * Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic.
33
+ * Defaults reconciliation key to `id`.
34
+ */
35
+ reconcile?:
36
+ | string
37
+ | false
38
+ | ((oldData: TData | undefined, newData: TData) => TData)
39
+ }
40
+
41
+ export interface InfiniteQueryObserverOptions<
42
+ TQueryFnData = unknown,
43
+ TError = DefaultError,
44
+ TData = TQueryFnData,
45
+ TQueryData = TQueryFnData,
46
+ TQueryKey extends QueryKey = QueryKey,
47
+ TPageParam = unknown,
48
+ > extends Omit<
49
+ QueryCoreInfiniteQueryObserverOptions<
50
+ TQueryFnData,
51
+ TError,
52
+ TData,
53
+ TQueryData,
54
+ TQueryKey,
55
+ TPageParam
56
+ >,
57
+ 'structuralSharing'
58
+ > {
59
+ /**
60
+ * Set this to a reconciliation key to enable reconciliation between query results.
61
+ * Set this to `false` to disable reconciliation between query results.
62
+ * Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic.
63
+ * Defaults reconciliation key to `id`.
64
+ */
65
+ reconcile?:
66
+ | string
67
+ | false
68
+ | ((oldData: TData | undefined, newData: TData) => TData)
69
+ }
70
+
71
+ export interface DefaultOptions<TError = DefaultError>
72
+ extends CoreDefaultOptions<TError> {
73
+ queries?: QueryObserverOptions<unknown, TError>
74
+ }
75
+
76
+ export interface QueryClientConfig extends QueryCoreClientConfig {
77
+ defaultOptions?: DefaultOptions
78
+ }
79
+
80
+ export class QueryClient extends QueryCoreClient {
81
+ constructor(config: QueryClientConfig = {}) {
82
+ super(config)
83
+ }
84
+ }
@@ -1,4 +1,4 @@
1
- import type { QueryClient } from '@tanstack/query-core'
1
+ import type { QueryClient } from './QueryClient'
2
2
  import type { JSX } from 'solid-js'
3
3
  import { createContext, useContext, onMount, onCleanup } from 'solid-js'
4
4
 
@@ -1,9 +1,8 @@
1
- import { render, screen, waitFor } from 'solid-testing-library'
2
- import { queryKey } from './utils'
1
+ import { render, screen, waitFor } from '@solidjs/testing-library'
2
+ import { createQueryClient, sleep, queryKey } from './utils'
3
3
 
4
4
  import { QueryCache } from '@tanstack/query-core'
5
5
  import { createQuery, QueryClientProvider, useQueryClient } from '..'
6
- import { createQueryClient, sleep } from './utils'
7
6
  import { vi } from 'vitest'
8
7
 
9
8
  describe('QueryClientProvider', () => {
@@ -1,6 +1,12 @@
1
- import { fireEvent, render, screen, waitFor } from 'solid-testing-library'
1
+ import { fireEvent, render, screen, waitFor } from '@solidjs/testing-library'
2
2
 
3
- import { createQueryClient, sleep } from './utils'
3
+ import {
4
+ createQueryClient,
5
+ sleep,
6
+ Blink,
7
+ queryKey,
8
+ setActTimeout,
9
+ } from './utils'
4
10
 
5
11
  import {
6
12
  createEffect,
@@ -10,6 +16,7 @@ import {
10
16
  Index,
11
17
  Match,
12
18
  Switch,
19
+ on,
13
20
  } from 'solid-js'
14
21
  import type {
15
22
  CreateInfiniteQueryResult,
@@ -22,7 +29,6 @@ import {
22
29
  QueryClientProvider,
23
30
  keepPreviousData,
24
31
  } from '..'
25
- import { Blink, queryKey, setActTimeout } from './utils'
26
32
  import { vi } from 'vitest'
27
33
  import type { Mock } from 'vitest'
28
34
 
@@ -193,7 +199,8 @@ describe('useInfiniteQuery', () => {
193
199
 
194
200
  it('should keep the previous data when placeholderData is set', async () => {
195
201
  const key = queryKey()
196
- const states: CreateInfiniteQueryResult<InfiniteData<string>>[] = []
202
+ const states: Partial<CreateInfiniteQueryResult<InfiniteData<string>>>[] =
203
+ []
197
204
 
198
205
  function Page() {
199
206
  const [order, setOrder] = createSignal('desc')
@@ -212,7 +219,16 @@ describe('useInfiniteQuery', () => {
212
219
  }))
213
220
 
214
221
  createRenderEffect(() => {
215
- states.push({ ...state })
222
+ states.push({
223
+ data: state.data ? JSON.parse(JSON.stringify(state.data)) : undefined,
224
+ hasNextPage: state.hasNextPage,
225
+ hasPreviousPage: state.hasPreviousPage,
226
+ isFetching: state.isFetching,
227
+ isFetchingNextPage: state.isFetchingNextPage,
228
+ isFetchingPreviousPage: state.isFetchingPreviousPage,
229
+ isSuccess: state.isSuccess,
230
+ isPlaceholderData: state.isPlaceholderData,
231
+ })
216
232
  })
217
233
 
218
234
  return (
@@ -375,7 +391,8 @@ describe('useInfiniteQuery', () => {
375
391
 
376
392
  it('should be able to reverse the data', async () => {
377
393
  const key = queryKey()
378
- const states: CreateInfiniteQueryResult<InfiniteData<number>>[] = []
394
+ const states: Partial<CreateInfiniteQueryResult<InfiniteData<number>>>[] =
395
+ []
379
396
 
380
397
  function Page() {
381
398
  const state = createInfiniteQuery(() => ({
@@ -394,9 +411,19 @@ describe('useInfiniteQuery', () => {
394
411
  defaultPageParam: 0,
395
412
  }))
396
413
 
397
- createRenderEffect(() => {
398
- states.push({ ...state })
399
- })
414
+ createRenderEffect(
415
+ on(
416
+ () => ({ ...state }),
417
+ () => {
418
+ states.push({
419
+ data: state.data
420
+ ? JSON.parse(JSON.stringify(state.data))
421
+ : undefined,
422
+ isSuccess: state.isSuccess,
423
+ })
424
+ },
425
+ ),
426
+ )
400
427
 
401
428
  return (
402
429
  <div>
@@ -439,7 +466,8 @@ describe('useInfiniteQuery', () => {
439
466
 
440
467
  it('should be able to fetch a previous page', async () => {
441
468
  const key = queryKey()
442
- const states: CreateInfiniteQueryResult<InfiniteData<number>>[] = []
469
+ const states: Partial<CreateInfiniteQueryResult<InfiniteData<number>>>[] =
470
+ []
443
471
 
444
472
  function Page() {
445
473
  const start = 10
@@ -456,7 +484,15 @@ describe('useInfiniteQuery', () => {
456
484
  }))
457
485
 
458
486
  createRenderEffect(() => {
459
- states.push({ ...state })
487
+ states.push({
488
+ data: state.data ? JSON.parse(JSON.stringify(state.data)) : undefined,
489
+ hasNextPage: state.hasNextPage,
490
+ hasPreviousPage: state.hasPreviousPage,
491
+ isFetching: state.isFetching,
492
+ isFetchingNextPage: state.isFetchingNextPage,
493
+ isFetchingPreviousPage: state.isFetchingPreviousPage,
494
+ isSuccess: state.isSuccess,
495
+ })
460
496
  })
461
497
 
462
498
  createEffect(() => {
@@ -518,7 +554,8 @@ describe('useInfiniteQuery', () => {
518
554
 
519
555
  it('should be able to refetch when providing page params automatically', async () => {
520
556
  const key = queryKey()
521
- const states: CreateInfiniteQueryResult<InfiniteData<number>>[] = []
557
+ const states: Partial<CreateInfiniteQueryResult<InfiniteData<number>>>[] =
558
+ []
522
559
 
523
560
  function Page() {
524
561
  const state = createInfiniteQuery(() => ({
@@ -535,7 +572,13 @@ describe('useInfiniteQuery', () => {
535
572
  }))
536
573
 
537
574
  createRenderEffect(() => {
538
- states.push({ ...state })
575
+ states.push({
576
+ data: state.data ? JSON.parse(JSON.stringify(state.data)) : undefined,
577
+ isFetching: state.isFetching,
578
+ isFetchingNextPage: state.isFetchingNextPage,
579
+ isRefetching: state.isRefetching,
580
+ isFetchingPreviousPage: state.isFetchingPreviousPage,
581
+ })
539
582
  })
540
583
 
541
584
  return (
@@ -632,7 +675,8 @@ describe('useInfiniteQuery', () => {
632
675
 
633
676
  it('should silently cancel any ongoing fetch when fetching more', async () => {
634
677
  const key = queryKey()
635
- const states: CreateInfiniteQueryResult<InfiniteData<number>>[] = []
678
+ const states: Partial<CreateInfiniteQueryResult<InfiniteData<number>>>[] =
679
+ []
636
680
 
637
681
  function Page() {
638
682
  const start = 10
@@ -649,7 +693,13 @@ describe('useInfiniteQuery', () => {
649
693
  }))
650
694
 
651
695
  createRenderEffect(() => {
652
- states.push({ ...state })
696
+ states.push({
697
+ hasNextPage: state.hasNextPage,
698
+ data: state.data ? JSON.parse(JSON.stringify(state.data)) : undefined,
699
+ isFetching: state.isFetching,
700
+ isFetchingNextPage: state.isFetchingNextPage,
701
+ isSuccess: state.isSuccess,
702
+ })
653
703
  })
654
704
 
655
705
  createEffect(() => {
@@ -978,7 +1028,8 @@ describe('useInfiniteQuery', () => {
978
1028
 
979
1029
  it('should be able to set new pages with the query client', async () => {
980
1030
  const key = queryKey()
981
- const states: CreateInfiniteQueryResult<InfiniteData<number>>[] = []
1031
+ const states: Partial<CreateInfiniteQueryResult<InfiniteData<number>>>[] =
1032
+ []
982
1033
 
983
1034
  function Page() {
984
1035
  const [firstPage, setFirstPage] = createSignal(0)
@@ -996,7 +1047,13 @@ describe('useInfiniteQuery', () => {
996
1047
  }))
997
1048
 
998
1049
  createRenderEffect(() => {
999
- states.push({ ...state })
1050
+ states.push({
1051
+ hasNextPage: state.hasNextPage,
1052
+ data: state.data ? JSON.parse(JSON.stringify(state.data)) : undefined,
1053
+ isFetching: state.isFetching,
1054
+ isFetchingNextPage: state.isFetchingNextPage,
1055
+ isSuccess: state.isSuccess,
1056
+ })
1000
1057
  })
1001
1058
 
1002
1059
  createEffect(() => {
@@ -1066,7 +1123,8 @@ describe('useInfiniteQuery', () => {
1066
1123
 
1067
1124
  it('should only refetch the first page when initialData is provided', async () => {
1068
1125
  const key = queryKey()
1069
- const states: CreateInfiniteQueryResult<InfiniteData<number>>[] = []
1126
+ const states: Partial<CreateInfiniteQueryResult<InfiniteData<number>>>[] =
1127
+ []
1070
1128
 
1071
1129
  function Page() {
1072
1130
  const state = createInfiniteQuery(() => ({
@@ -1083,7 +1141,13 @@ describe('useInfiniteQuery', () => {
1083
1141
  }))
1084
1142
 
1085
1143
  createRenderEffect(() => {
1086
- states.push({ ...state })
1144
+ states.push({
1145
+ data: JSON.parse(JSON.stringify(state.data)),
1146
+ hasNextPage: state.hasNextPage,
1147
+ isFetching: state.isFetching,
1148
+ isFetchingNextPage: state.isFetchingNextPage,
1149
+ isSuccess: state.isSuccess,
1150
+ })
1087
1151
  })
1088
1152
 
1089
1153
  createEffect(() => {
@@ -5,7 +5,7 @@ import {
5
5
  createSignal,
6
6
  ErrorBoundary,
7
7
  } from 'solid-js'
8
- import { fireEvent, render, screen, waitFor } from 'solid-testing-library'
8
+ import { fireEvent, render, screen, waitFor } from '@solidjs/testing-library'
9
9
  import {
10
10
  createMutation,
11
11
  MutationCache,
@@ -781,7 +781,7 @@ describe('createMutation', () => {
781
781
  fireEvent.click(screen.getByText('unmount'))
782
782
  })
783
783
 
784
- it('should be able to throw an error when throwErrors is set to true', async () => {
784
+ it('should be able to throw an error when throwOnError is set to true', async () => {
785
785
  function Page() {
786
786
  const mutation = createMutation<string, Error>(() => ({
787
787
  mutationFn: () => {
@@ -789,7 +789,7 @@ describe('createMutation', () => {
789
789
  err.stack = ''
790
790
  return Promise.reject(err)
791
791
  },
792
- throwErrors: true,
792
+ throwOnError: true,
793
793
  }))
794
794
 
795
795
  return (
@@ -820,7 +820,7 @@ describe('createMutation', () => {
820
820
  })
821
821
  })
822
822
 
823
- it('should be able to throw an error when throwErrors is a function that returns true', async () => {
823
+ it('should be able to throw an error when throwOnError is a function that returns true', async () => {
824
824
  let boundary = false
825
825
  function Page() {
826
826
  const mutation = createMutation<string, Error>(() => ({
@@ -829,7 +829,7 @@ describe('createMutation', () => {
829
829
  err.stack = ''
830
830
  return Promise.reject(err)
831
831
  },
832
- throwErrors: () => {
832
+ throwOnError: () => {
833
833
  boundary = !boundary
834
834
  return !boundary
835
835
  },
@@ -1,6 +1,5 @@
1
- import { fireEvent, render, screen, waitFor } from 'solid-testing-library'
2
-
3
- import * as QueriesObserverModule from '../../../query-core/src/queriesObserver'
1
+ import { fireEvent, render, screen, waitFor } from '@solidjs/testing-library'
2
+ import * as QueryCore from '@tanstack/query-core'
4
3
 
5
4
  import type { QueryFunctionContext, QueryKey } from '@tanstack/query-core'
6
5
  import { createRenderEffect, createSignal } from 'solid-js'
@@ -158,10 +157,6 @@ describe('useQueries', () => {
158
157
  expectTypeNotAny(a)
159
158
  return a.toLowerCase()
160
159
  },
161
- onSuccess: (a) => {
162
- expectType<string>(a)
163
- expectTypeNotAny(a)
164
- },
165
160
  placeholderData: 'string',
166
161
  // @ts-expect-error (initialData: string)
167
162
  initialData: 123,
@@ -174,14 +169,6 @@ describe('useQueries', () => {
174
169
  expectTypeNotAny(a)
175
170
  return parseInt(a)
176
171
  },
177
- onSuccess: (a) => {
178
- expectType<number>(a)
179
- expectTypeNotAny(a)
180
- },
181
- onError: (e) => {
182
- expectType<boolean>(e)
183
- expectTypeNotAny(e)
184
- },
185
172
  placeholderData: 'string',
186
173
  // @ts-expect-error (initialData: string)
187
174
  initialData: 123,
@@ -319,10 +306,6 @@ describe('useQueries', () => {
319
306
  expectTypeNotAny(a)
320
307
  return a.toLowerCase()
321
308
  },
322
- onSuccess: (a) => {
323
- expectType<string>(a)
324
- expectTypeNotAny(a)
325
- },
326
309
  placeholderData: 'string',
327
310
  // @ts-expect-error (initialData: string)
328
311
  initialData: 123,
@@ -335,14 +318,6 @@ describe('useQueries', () => {
335
318
  expectTypeNotAny(a)
336
319
  return parseInt(a)
337
320
  },
338
- onSuccess: (a) => {
339
- expectType<number>(a)
340
- expectTypeNotAny(a)
341
- },
342
- onError: (e) => {
343
- expectType<boolean>(e)
344
- expectTypeNotAny(e)
345
- },
346
321
  placeholderData: 'string',
347
322
  // @ts-expect-error (initialData: string)
348
323
  initialData: 123,
@@ -436,60 +411,38 @@ describe('useQueries', () => {
436
411
  ],
437
412
  }))
438
413
 
439
- // select / onSuccess / onSettled params are "indirectly" enforced
414
+ // select params are "indirectly" enforced
440
415
  createQueries(() => ({
441
416
  queries: [
442
417
  // unfortunately TS will not suggest the type for you
443
418
  {
444
419
  queryKey: key1,
445
420
  queryFn: () => 'string',
446
- // @ts-expect-error (noImplicitAny)
447
- onSuccess: (a) => null,
448
- // @ts-expect-error (noImplicitAny)
449
- onSettled: (a) => null,
450
421
  },
451
422
  // however you can add a type to the callback
452
423
  {
453
424
  queryKey: key2,
454
425
  queryFn: () => 'string',
455
- onSuccess: (a: string) => {
456
- expectType<string>(a)
457
- expectTypeNotAny(a)
458
- },
459
- onSettled: (a: string | undefined) => {
460
- expectType<string | undefined>(a)
461
- expectTypeNotAny(a)
462
- },
463
426
  },
464
427
  // the type you do pass is enforced
465
428
  {
466
429
  queryKey: key3,
467
430
  queryFn: () => 'string',
468
- // @ts-expect-error (only accepts string)
469
- onSuccess: (a: number) => null,
470
431
  },
471
432
  {
472
433
  queryKey: key4,
473
434
  queryFn: () => 'string',
474
435
  select: (a: string) => parseInt(a),
475
- // @ts-expect-error (select is defined => only accepts number)
476
- onSuccess: (a: string) => null,
477
- onSettled: (a: number | undefined) => {
478
- expectType<number | undefined>(a)
479
- expectTypeNotAny(a)
480
- },
481
436
  },
482
437
  ],
483
438
  }))
484
439
 
485
440
  // callbacks are also indirectly enforced with Array.map
486
441
  createQueries(() => ({
487
- // @ts-expect-error (onSuccess only accepts string)
488
442
  queries: Array(50).map((_, i) => ({
489
443
  queryKey: ['key', i] as const,
490
444
  queryFn: () => i + 10,
491
445
  select: (data: number) => data.toString(),
492
- onSuccess: (_data: number) => null,
493
446
  })),
494
447
  }))
495
448
 
@@ -498,7 +451,6 @@ describe('useQueries', () => {
498
451
  queryKey: ['key', i] as const,
499
452
  queryFn: () => i + 10,
500
453
  select: (data: number) => data.toString(),
501
- onSuccess: (_data: string) => null,
502
454
  })),
503
455
  }))
504
456
 
@@ -508,32 +460,15 @@ describe('useQueries', () => {
508
460
  {
509
461
  queryKey: key1,
510
462
  queryFn: () => 'string',
511
- // @ts-expect-error (noImplicitAny)
512
- onSuccess: (a) => null,
513
- // @ts-expect-error (noImplicitAny)
514
- onSettled: (a) => null,
515
463
  },
516
464
  {
517
465
  queryKey: key2,
518
466
  queryFn: () => 'string',
519
- onSuccess: (a: string) => {
520
- expectType<string>(a)
521
- expectTypeNotAny(a)
522
- },
523
- onSettled: (a: string | undefined) => {
524
- expectType<string | undefined>(a)
525
- expectTypeNotAny(a)
526
- },
527
467
  },
528
468
  {
529
469
  queryKey: key4,
530
470
  queryFn: () => 'string',
531
471
  select: (a: string) => parseInt(a),
532
- onSuccess: (_a: number) => null,
533
- onSettled: (a: number | undefined) => {
534
- expectType<number | undefined>(a)
535
- expectTypeNotAny(a)
536
- },
537
472
  },
538
473
  ],
539
474
  }))
@@ -547,12 +482,6 @@ describe('useQueries', () => {
547
482
  {
548
483
  queryKey: key1,
549
484
  queryFn: () => Promise.resolve('string'),
550
- onSuccess: (a: string) => {
551
- expectType<string>(a)
552
- expectTypeNotAny(a)
553
- },
554
- // @ts-expect-error (refuses to accept a Promise)
555
- onSettled: (a: Promise<string>) => null,
556
485
  },
557
486
  ],
558
487
  }))
@@ -658,11 +587,10 @@ describe('useQueries', () => {
658
587
  queries: queries.map(
659
588
  // no need to type the mapped query
660
589
  (query) => {
661
- const { queryFn: fn, queryKey: key, onError: err } = query
590
+ const { queryFn: fn, queryKey: key } = query
662
591
  expectType<QueryFunction<TQueryFnData, TQueryKey> | undefined>(fn)
663
592
  return {
664
593
  queryKey: key,
665
- onError: err,
666
594
  queryFn: fn
667
595
  ? (ctx: QueryFunctionContext<TQueryKey>) => {
668
596
  expectType<TQueryKey>(ctx.queryKey)
@@ -741,9 +669,9 @@ describe('useQueries', () => {
741
669
  }
742
670
 
743
671
  const QueriesObserverSpy = vi
744
- .spyOn(QueriesObserverModule, 'QueriesObserver')
672
+ .spyOn(QueryCore, 'QueriesObserver')
745
673
  .mockImplementation((fn) => {
746
- return new QueriesObserverMock(fn)
674
+ return new QueriesObserverMock(fn, [])
747
675
  })
748
676
 
749
677
  function Queries() {