Open History to see the last commit
1// Definitions by: Lukasz Fiszer <https://github.com/lukaszfiszer>
2// Jace Hensley <https://github.com/jacehensley>
3// Matteo Frana <https://github.com/matteofrana>
4// Igor Oleinikov <https://github.com/igorbek>
5// Minimum TypeScript Version: 3.7
6β
7import * as React from 'react'
8import * as _ from 'ts-toolbelt'
9β
10// overloaded useQuery function
11export function useQuery<
12 TResult,
13 TKey extends AnyQueryKey,
14 TVariables extends AnyVariables = [],
15 TError = Error
16>({
17 queryKey,
18 variables,
19 queryFn,
20 config,
21}: {
22 queryKey:
23 | TKey
24 | false
25 | null
26 | undefined
27 | (() => TKey | false | null | undefined)
28 variables?: TVariables
29 queryFn: QueryFunctionWithVariables<TResult, TKey, TVariables>
30 config?: QueryOptions<TResult, TError>
31}): QueryResult<TResult, TError>
32β
33export function useQuery<
34 TResult,
35 TSingleKey extends string,
36 TVariables extends AnyVariables = [],
37 TError = Error
38>({
39 queryKey,
40 variables,
41 queryFn,
42 config,
43}: {
44 queryKey:
45 | TSingleKey
46 | false
47 | null
48 | undefined
49 | (() => TSingleKey | false | null | undefined)
50 variables?: TVariables
51 queryFn: QueryFunctionWithVariables<TResult, [TSingleKey], TVariables>
52 config?: QueryOptions<TResult, TError>
53}): QueryResult<TResult, TError>
54β
55export function useQuery<TResult, TKey extends AnyQueryKey, TError = Error>(
56 queryKey:
57 | TKey
58 | false
59 | null
60 | undefined
61 | (() => TKey | false | null | undefined),
62 queryFn: QueryFunction<TResult, TKey>,
63 config?: QueryOptions<TResult, TError>
64): QueryResult<TResult, TError>
65β
66export function useQuery<TResult, TSingleKey extends string, TError = Error>(
67 queryKey:
68 | TSingleKey
69 | false
70 | null
71 | undefined
72 | (() => TSingleKey | false | null | undefined),
73 queryFn: QueryFunction<TResult, [TSingleKey]>,
74 config?: QueryOptions<TResult, TError>
75): QueryResult<TResult, TError>
76β
77export function useQuery<
78 TResult,
79 TKey extends AnyQueryKey,
80 TVariables extends AnyVariables,
81 TError = Error
82>(
83 queryKey:
84 | TKey
85 | false
86 | null
87 | undefined
88 | (() => TKey | false | null | undefined),
89 variables: TVariables,
90 queryFn: QueryFunctionWithVariables<TResult, TKey, TVariables>,
91 config?: QueryOptions<TResult, TError>
92): QueryResult<TResult, TError>
93β
94export function useQuery<
95 TResult,
96 TKey extends string,
97 TVariables extends AnyVariables,
98 TError = Error
99>(
100 queryKey:
101 | TKey
102 | false
103 | null
104 | undefined
105 | (() => TKey | false | null | undefined),
106 variables: TVariables,
107 queryFn: QueryFunctionWithVariables<TResult, [TKey], TVariables>,
108 config?: QueryOptions<TResult, TError>
109): QueryResult<TResult, TError>
110β
111// usePaginatedQuery
112export function usePaginatedQuery<
113 TResult,
114 TKey extends AnyQueryKey,
115 TVariables extends AnyVariables = [],
116 TError = Error
117>({
118 queryKey,
119 variables,
120 queryFn,
121 config,
122}: {
123 queryKey:
124 | TKey
125 | false
126 | null
127 | undefined
128 | (() => TKey | false | null | undefined)
129 variables?: TVariables
130 queryFn: QueryFunctionWithVariables<TResult, TKey, TVariables>
131 config?: QueryOptions<TResult, TError>
132}): PaginatedQueryResult<TResult, TError>
133β
134export function usePaginatedQuery<
135 TResult,
136 TSingleKey extends string,
137 TVariables extends AnyVariables = [],
138TError = Error
139>({
140 queryKey,
141 variables,
142 queryFn,
143 config,
144}: {
145 queryKey:
146 | TSingleKey
147 | false
148 | null
149 | undefined
150 | (() => TSingleKey | false | null | undefined)
151 variables?: TVariables
152 queryFn: QueryFunctionWithVariables<TResult, [TSingleKey], TVariables>
153 config?: QueryOptions<TResult, TError>
154}): PaginatedQueryResult<TResult, TError>
155β
156export function usePaginatedQuery<TResult, TKey extends AnyQueryKey, TError = Error>(
157 queryKey:
158 | TKey
159 | false
160 | null
161 | undefined
162 | (() => TKey | false | null | undefined),
163 queryFn: QueryFunction<TResult, TKey>,
164 config?: QueryOptions<TResult, TError>
165): PaginatedQueryResult<TResult, TError>
166β
167export function usePaginatedQuery<TResult, TKey extends string, TError = Error>(
168 queryKey:
169 | TKey
170 | false
171 | null
172 | undefined
173 | (() => TKey | false | null | undefined),
174 queryFn: QueryFunction<TResult, [TKey]>,
175 config?: QueryOptions<TResult, TError>
176): PaginatedQueryResult<TResult, TError>
177β
178export function usePaginatedQuery<
179 TResult,
180 TKey extends AnyQueryKey,
181 TVariables extends AnyVariables,
182TError = Error
183>(
184 queryKey:
185 | TKey
186 | false
187 | null
188 | undefined
189 | (() => TKey | false | null | undefined),
190 variables: TVariables,
191 queryFn: QueryFunctionWithVariables<TResult, TKey, TVariables>,
192 config?: QueryOptions<TResult, TError>
193): PaginatedQueryResult<TResult, TError>
194β
195export function usePaginatedQuery<
196 TResult,
197 TKey extends string,
198 TVariables extends AnyVariables,
199 TError = Error
200>(
201 queryKey:
202 | TKey
203 | false
204 | null
205 | undefined
206 | (() => TKey | false | null | undefined),
207 variables: TVariables,
208 queryFn: QueryFunctionWithVariables<TResult, [TKey], TVariables>,
209 config?: QueryOptions<TResult, TError>
210): PaginatedQueryResult<TResult, TError>
211β
212// useInfiniteQuery
213export function useInfiniteQuery<
214 TResult,
215 TKey extends AnyQueryKey,
216 TMoreVariable,
217 TVariables extends AnyVariables = [],
218 TError = Error
219>({
220 queryKey,
221 variables,
222 queryFn,
223 config,
224}: {
225 queryKey:
226 | TKey
227 | false
228 | null
229 | undefined
230 | (() => TKey | false | null | undefined)
231 variables?: TVariables
232 queryFn: InfiniteQueryFunctionWithVariables<
233 TResult,
234 TKey,
235 TVariables,
236 TMoreVariable
237 >
238 config?: InfiniteQueryOptions<TResult, TMoreVariable, TError>
239}): InfiniteQueryResult<TResult, TMoreVariable, TError>
240β
241export function useInfiniteQuery<
242 TResult,
243 TSingleKey extends string,
244 TMoreVariable,
245 TVariables extends AnyVariables = [],
246 TError = Error
247>({
248 queryKey,
249 variables,
250 queryFn,
251 config,
252}: {
253 queryKey:
254 | TSingleKey
255 | false
256 | null
257 | undefined
258 | (() => TSingleKey | false | null | undefined)
259 variables?: TVariables
260 queryFn: InfiniteQueryFunctionWithVariables<
261 TResult,
262 [TSingleKey],
263 TVariables,
264 TMoreVariable
265 >
266 config?: InfiniteQueryOptions<TResult, TMoreVariable, TError>
267}): InfiniteQueryResult<TResult, TMoreVariable, TError>
268β
269export function useInfiniteQuery<
270 TResult,
271 TKey extends AnyQueryKey,
272 TMoreVariable,
273 TError = Error
274>(
275 queryKey:
276 | TKey
277 | false
278 | null
279 | undefined
280 | (() => TKey | false | null | undefined),
281 queryFn: InfiniteQueryFunction<TResult, TKey, TMoreVariable>,
282 config?: InfiniteQueryOptions<TResult, TMoreVariable, TError>
283): InfiniteQueryResult<TResult, TMoreVariable, TError>
284β
285export function useInfiniteQuery<TResult, TKey extends string, TMoreVariable, TError = Error>(
286 queryKey:
287 | TKey
288 | false
289 | null
290 | undefined
291 | (() => TKey | false | null | undefined),
292 queryFn: InfiniteQueryFunction<TResult, [TKey], TMoreVariable>,
293 config?: InfiniteQueryOptions<TResult, TMoreVariable, TError>
294): InfiniteQueryResult<TResult, TMoreVariable, TError>
295β
296export function useInfiniteQuery<
297 TResult,
298 TKey extends AnyQueryKey,
299 TVariables extends AnyVariables,
300 TMoreVariable,
301 TError = Error
302>(
303 queryKey:
304 | TKey
305 | false
306 | null
307 | undefined
308 | (() => TKey | false | null | undefined),
309 variables: TVariables,
310 queryFn: InfiniteQueryFunctionWithVariables<
311 TResult,
312 TKey,
313 TVariables,
314 TMoreVariable
315 >,
316 config?: InfiniteQueryOptions<TResult, TMoreVariable, TError>
317): InfiniteQueryResult<TResult, TMoreVariable, TError>
318β
319export function useInfiniteQuery<
320 TResult,
321 TKey extends string,
322 TVariables extends AnyVariables,
323 TMoreVariable,
324 TError = Error
325>(
326 queryKey:
327 | TKey
328 | false
329 | null
330 | undefined
331 | (() => TKey | false | null | undefined),
332 variables: TVariables,
333 queryFn: InfiniteQueryFunctionWithVariables<
334 TResult,
335 [TKey],
336 TVariables,
337 TMoreVariable
338 >,
339 config?: InfiniteQueryOptions<TResult, TMoreVariable, TError>
340): InfiniteQueryResult<TResult, TMoreVariable, TError>
341β
342export type DefinedQueryKeyPart =
343 | string
344 | object
345 | boolean
346 | number
347 | readonly QueryKeyPart[]
348β
349export type QueryKeyPart =
350 | string
351 | object
352 | boolean
353 | number
354 | readonly QueryKeyPart[]
355 | null
356 | undefined
357β
358export type AnyQueryKey = readonly [DefinedQueryKeyPart, ...QueryKeyPart[]] // this forces the key to be inferred as a tuple
359β
360export type AnyVariables = readonly [] | readonly [any, ...any[]] // this forces the variables to be inferred as a tuple
361β
362export type QueryFunction<TResult, TKey extends AnyQueryKey> = (
363 ...key: TKey
364) => Promise<TResult>
365β
366export type QueryFunctionWithVariables<
367 TResult,
368 TKey extends AnyQueryKey,
369 TVariables extends AnyVariables
370> = (...key: _.List.Concat<TKey, TVariables>) => Promise<TResult>
371β
372export type InfiniteQueryFunction<
373 TResult,
374 TKey extends AnyQueryKey,
375 TMoreVariable
376> = (
377 ...keysAndMore: _.List.Append<TKey, TMoreVariable> | TKey
378) => Promise<TResult>
379β
380export type InfiniteQueryFunctionWithVariables<
381 TResult,
382 TKey extends AnyQueryKey,
383 TVariables extends AnyVariables,
384 TMoreVariable
385> = (
386 ...keysAndVariablesAndMore:
387 | _.List.Append<_.List.Concat<TKey, TVariables>, TMoreVariable>
388 | _.List.Concat<TKey, TVariables>
389) => Promise<TResult>
390β
391export interface BaseQueryOptions<TError = Error> {
392 /**
393 * Set this to `true` to disable automatic refetching when the query mounts or changes query keys.
394 * To refetch the query, use the `refetch` method returned from the `useQuery` instance.
395 */
396 manual?: boolean
397 /**
398 * If `false`, failed queries will not retry by default.
399 * If `true`, failed queries will retry infinitely., failureCount: num
400 * If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number.
401 * If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false.
402 */
403 retry?: boolean | number | ((failureCount: number, error: TError) => boolean)
404 retryDelay?: (retryAttempt: number) => number
405 staleTime?: number
406 cacheTime?: number
407 refetchInterval?: false | number
408 refetchIntervalInBackground?: boolean
409 refetchOnWindowFocus?: boolean
410 refetchOnMount?: boolean
411 onError?: (err: TError) => void
412 suspense?: boolean
413 isDataEqual?: (oldData: unknown, newData: unknown) => boolean
414}
415β
416export interface QueryOptions<TResult, TError = Error> extends BaseQueryOptions<TError> {
417 onSuccess?: (data: TResult) => void
418 onSettled?: (data: TResult | undefined, error: TError | null) => void
419 initialData?: TResult | (() => TResult | undefined)
420}
421β
422export interface PrefetchQueryOptions<TResult, TError = Error> extends QueryOptions<TResult, TError> {
423 force?: boolean
424 throwOnError?: boolean
425}
426β
427export interface SetQueryDataQueryOptions<TResult, TError = Error> extends QueryOptions<TResult, TError> {
428 exact?: boolean
429}
430β
431export interface InfiniteQueryOptions<TResult, TMoreVariable, TError = Error>
432 extends QueryOptions<TResult[], TError> {
433 getFetchMore: (
434 lastPage: TResult,
435 allPages: TResult[]
436 ) => TMoreVariable | false
437}
438β
439export interface QueryResultBase<TResult, TError = Error> {
440 status: 'loading' | 'error' | 'success'
441 error: null | TError
442 isFetching: boolean
443 isStale: boolean
444 failureCount: number
445 refetch: ({
446 force,
447 throwOnError,
448 }?: {
449 force?: boolean
450 throwOnError?: boolean
451 }) => Promise<TResult>
452}
453β
454export interface QueryLoadingResult<TResult, TError = Error> extends QueryResultBase<TResult, TError> {
455 status: 'loading'
456 data: TResult | undefined // even when error, data can have stale data
457 error: TError | null // it still can be error
458}
459β
460export interface QueryErrorResult<TResult, TError = Error> extends QueryResultBase<TResult, TError> {
461 status: 'error'
462 data: TResult | undefined // even when error, data can have stale data
463 error: TError
464}
465β
466export interface QuerySuccessResult<TResult> extends QueryResultBase<TResult> {
467 status: 'success'
468 data: TResult
469 error: null
470}
471β
472export type QueryResult<TResult, TError = Error> =
473 | QueryLoadingResult<TResult, TError>
474 | QueryErrorResult<TResult, TError>
475 | QuerySuccessResult<TResult>
476β
477export interface PaginatedQueryLoadingResult<TResult, TError = Error>
478 extends QueryResultBase<TResult, TError> {
479 status: 'loading'
480 resolvedData: undefined | TResult // even when error, data can have stale data
481 latestData: undefined | TResult // even when error, data can have stale data
482 error: null | TError // it still can be error
483}
484β
485export interface PaginatedQueryErrorResult<TResult, TError = Error>
486 extends QueryResultBase<TResult, TError> {
487 status: 'error'
488 resolvedData: undefined | TResult // even when error, data can have stale data
489 latestData: undefined | TResult // even when error, data can have stale data
490 error: TError
491}
492β
493export interface PaginatedQuerySuccessResult<TResult>
494 extends QueryResultBase<TResult> {
495 status: 'success'
496 resolvedData: TResult
497 latestData: TResult
498 error: null
499}
500β
501export type PaginatedQueryResult<TResult, TError = Error> =
502 | PaginatedQueryLoadingResult<TResult, TError>
503 | PaginatedQueryErrorResult<TResult, TError>
504 | PaginatedQuerySuccessResult<TResult>
505β
506export interface InfiniteQueryResult<TResult, TMoreVariable, TError = Error>
507 extends QueryResultBase<TResult[], TError> {
508 data: TResult[]
509 isFetchingMore: boolean
510 canFetchMore: boolean | undefined
511 fetchMore: (
512 moreVariable?: TMoreVariable | false
513 ) => Promise<TResult[]> | undefined
514}
515β
516export function useMutation<TResults, TVariables = undefined, TError = Error>(
517 mutationFn: MutationFunction<TResults, TVariables, TError>,
518 mutationOptions?: MutationOptions<TResults, TVariables, TError>
519): [MutateFunction<TResults, TVariables, TError>, MutationResult<TResults, TError>]
520β
521export type MutationFunction<TResults, TVariables, TError = Error> = (
522 variables: TVariables,
523 mutateOptions?: MutateOptions<TResults, TVariables, TError>,
524) => Promise<TResults>
525β
526export interface MutateOptions<TResult, TVariables, TError = Error> {
527 onSuccess?: (data: TResult, variables: TVariables) => Promise<void> | void
528 onError?: (
529 error: TError,
530 variables: TVariables,
531 snapshotValue: unknown
532 ) => Promise<void> | void
533 onSettled?: (
534 data: undefined | TResult,
535 error: TError | null,
536 variables: TVariables,
537 snapshotValue?: unknown
538 ) => Promise<void> | void
539 throwOnError?: boolean
540}
541β
542export interface MutationOptions<TResult, TVariables, TError = Error>
543 extends MutateOptions<TResult, TVariables, TError> {
544 onMutate?: (variables: TVariables) => Promise<unknown> | unknown
545 useErrorBoundary?: boolean
546}
547β
548export type MutateFunction<TResult, TVariables, TError = Error> = undefined extends TVariables
549 ? (
550 variables?: TVariables,
551 options?: MutateOptions<TResult, TVariables, TError>
552 ) => Promise<TResult>
553 : (
554 variables: TVariables,
555 options?: MutateOptions<TResult, TVariables, TError>
556 ) => Promise<TResult>
557β
558export interface MutationResultBase<TResult, TError = Error> {
559 status: 'idle' | 'loading' | 'error' | 'success'
560 data: undefined | TResult
561 error: undefined | null | TError
562 promise: Promise<TResult>
563 reset: () => void
564}
565β
566export interface IdleMutationResult<TResult, TError = Error>
567 extends MutationResultBase<TResult, TError> {
568 status: 'idle'
569 data: undefined
570 error: null
571}
572β
573export interface LoadingMutationResult<TResult, TError = Error>
574 extends MutationResultBase<TResult, TError> {
575 status: 'loading'
576 data: undefined
577 error: undefined
578}
579β
580export interface ErrorMutationResult<TResult, TError = Error>
581 extends MutationResultBase<TResult, TError> {
582 status: 'error'
583 data: undefined
584 error: TError
585}
586β
587export interface SuccessMutationResult<TResult>
588 extends MutationResultBase<TResult> {
589 status: 'success'
590 data: TResult
591 error: undefined
592}
593β
594export type MutationResult<TResult, TError = Error> =
595 | IdleMutationResult<TResult, TError>
596 | LoadingMutationResult<TResult, TError>
597 | ErrorMutationResult<TResult, TError>
598 | SuccessMutationResult<TResult>
599β
600export interface CachedQueryState<T> {
601 data?: T
602 error?: Error | null
603 failureCount: number
604 isFetching: boolean
605 canFetchMore?: boolean
606 isStale: boolean
607 status: 'loading' | 'error' | 'success'
608 updatedAt: number
609}
610β
611export interface CachedQuery<T, TError = unknown> {
612 queryKey: AnyQueryKey
613 queryVariables: AnyVariables
614 queryFn: (...args: any[]) => unknown
615 config: QueryOptions<unknown, TError>
616 state: CachedQueryState<T>
617 setData(
618 dataOrUpdater: unknown | undefined | ((oldData: unknown | undefined) => unknown | undefined)
619 ): void
620 clear(): void
621}
622β
623export interface QueryCache {
624 prefetchQuery<TResult, TKey extends AnyQueryKey, TError = Error>(
625 queryKey:
626 | TKey
627 | false
628 | null
629 | undefined
630 | (() => TKey | false | null | undefined),
631 queryFn: QueryFunction<TResult, TKey>,
632 config?: PrefetchQueryOptions<TResult, TError>
633 ): Promise<TResult>
634β
635 prefetchQuery<TResult, TKey extends string, TError = Error>(
636 queryKey:
637 | TKey
638 | false
639 | null
640 | undefined
641 | (() => TKey | false | null | undefined),
642 queryFn: QueryFunction<TResult, [TKey]>,
643 config?: PrefetchQueryOptions<TResult, TError>
644 ): Promise<TResult>
645β
646 prefetchQuery<
647 TResult,
648 TKey extends AnyQueryKey,
649 TVariables extends AnyVariables,
650 TError = Error
651 >(
652 queryKey:
653 | TKey
654 | false
655 | null
656 | undefined
657 | (() => TKey | false | null | undefined),
658 variables: TVariables,
659 queryFn: QueryFunctionWithVariables<TResult, TKey, TVariables>,
660 config?: PrefetchQueryOptions<TResult, TError>
661 ): Promise<TResult>
662β
663 prefetchQuery<TResult, TKey extends string, TVariables extends AnyVariables, TError = Error>(
664 queryKey:
665 | TKey
666 | false
667 | null
668 | undefined
669 | (() => TKey | false | null | undefined),
670 variables: TVariables,
671 queryFn: QueryFunctionWithVariables<TResult, [TKey], TVariables>,
672 config?: PrefetchQueryOptions<TResult, TError>
673 ): Promise<TResult>
674β
675 prefetchQuery<
676 TResult,
677 TKey extends AnyQueryKey,
678 TVariables extends AnyVariables = [],
679 TError = Error
680 >({
681 queryKey,
682 variables,
683 queryFn,
684 config,
685 }: {
686 queryKey:
687 | TKey
688 | false
689 | null
690 | undefined
691 | (() => TKey | false | null | undefined)
692 variables?: TVariables
693 queryFn: QueryFunctionWithVariables<TResult, TKey, TVariables>
694 config?: PrefetchQueryOptions<TResult, TError>
695 }): Promise<TResult>
696β
697 getQueryData<T = unknown>(key: AnyQueryKey | string): T | undefined
698 setQueryData<TResult, TError>(
699 key: AnyQueryKey | string,
700 dataOrUpdater: TResult | undefined | ((oldData: TResult | undefined) => TResult | undefined),
701 config?: SetQueryDataQueryOptions<TResult, TError>
702 ): void
703 refetchQueries<TResult>(
704 queryKeyOrPredicateFn:
705 | AnyQueryKey
706 | string
707 | ((query: CachedQuery<unknown>) => boolean),
708 {
709 exact,
710 throwOnError,
711 force,
712 }?: { exact?: boolean; throwOnError?: boolean; force?: boolean }
713 ): Promise<TResult>
714 removeQueries(
715 queryKeyOrPredicateFn:
716 | AnyQueryKey
717 | string
718 | ((query: CachedQuery<unknown>) => boolean),
719 { exact }?: { exact?: boolean }
720 ): void
721 getQuery(queryKey: AnyQueryKey): CachedQuery<unknown> | undefined
722 getQueries(queryKey: AnyQueryKey): Array<CachedQuery<unknown>>
723 cancelQueries(
724 queryKeyOrPredicateFn:
725 | AnyQueryKey
726 | string
727 | ((query: CachedQuery<unknown>) => boolean),
728 { exact }?: { exact?: boolean }
729 ): void
730 isFetching: number
731 subscribe(callback: (queryCache: QueryCache) => void): () => void
732 clear(): void
733}
734β
735export const queryCache: QueryCache
736β
737/**
738 * a factory that creates a new query cache
739 */
740export function makeQueryCache(): QueryCache
741β
742/**
743 * A hook that uses the query cache context
744 */
745export function useQueryCache(): QueryCache
746β
747export const ReactQueryCacheProvider: React.ComponentType<{
748 queryCache?: QueryCache
749}>
750β
751/**
752 * A hook that returns the number of the queries that your application is loading or fetching in the background
753 * (useful for app-wide loading indicators).
754 * @returns the number of the queries that your application is currently loading or fetching in the background.
755 */
756export function useIsFetching(): number
757β
758export function ReactQueryConfigProvider<TError = Error>(props: {
759 config?: ReactQueryProviderConfig<TError>;
760 children?: React.ReactNode;
761}): React.ReactElement;
762β
763export interface ReactQueryProviderConfig<TError = Error> extends BaseQueryOptions<TError> {
764 /** Defaults to the value of `suspense` if not defined otherwise */
765 useErrorBoundary?: boolean
766 throwOnError?: boolean
767 refetchAllOnWindowFocus?: boolean
768 queryKeySerializerFn?: (
769 queryKey:
770 | QueryKeyPart[]
771 | string
772 | false
773 | undefined
774 | (() => QueryKeyPart[] | string | false | undefined)
775 ) => [string, QueryKeyPart[]] | []
776β
777 onMutate?: (variables: unknown) => Promise<unknown> | unknown
778 onSuccess?: (data: unknown, variables?: unknown) => void
779 onError?: (err: TError, snapshotValue?: unknown) => void
780 onSettled?: (
781 data: unknown | undefined,
782 error: TError | null,
783 snapshotValue?: unknown
784 ) => void
785 isDataEqual?: (oldData: unknown, newData: unknown) => boolean
786}
787β
788export type ConsoleFunction = (...args: any[]) => void
789export interface ConsoleObject {
790 log: ConsoleFunction
791 warn: ConsoleFunction
792 error: ConsoleFunction
793}
794β
795export function setConsole(consoleObject: ConsoleObject): void
796β
797export function deepIncludes(haystack: unknown, needle: unknown): boolean