forked from TanStack/query
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
86 lines (76 loc) · 2.25 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import type {
DefaultError,
DehydrateOptions,
HydrateOptions,
MutationCache,
MutationObserverOptions,
OmitKeyof,
QueryCache,
QueryObserverOptions,
} from '@tanstack/query-core'
import type { ComputedRef, Ref, UnwrapRef } from 'vue-demi'
type Primitive = string | number | boolean | bigint | symbol | undefined | null
type UnwrapLeaf =
| Primitive
| Function
| Date
| Error
| RegExp
| Map<any, any>
| WeakMap<any, any>
| Set<any>
| WeakSet<any>
export type MaybeRef<T> = Ref<T> | ComputedRef<T> | T
export type MaybeRefOrGetter<T> = MaybeRef<T> | (() => T)
export type MaybeRefDeep<T> = MaybeRef<
T extends Function
? T
: T extends object
? {
[Property in keyof T]: MaybeRefDeep<T[Property]>
}
: T
>
export type NoUnknown<T> = Equal<unknown, T> extends true ? never : T
export type Equal<TTargetA, TTargetB> =
(<T>() => T extends TTargetA ? 1 : 2) extends <T>() => T extends TTargetB
? 1
: 2
? true
: false
export type DeepUnwrapRef<T> = T extends UnwrapLeaf
? T
: T extends Ref<infer U>
? DeepUnwrapRef<U>
: T extends {}
? {
[Property in keyof T]: DeepUnwrapRef<T[Property]>
}
: UnwrapRef<T>
export type DistributiveOmit<T, TKeyOfAny extends keyof any> = T extends any
? Omit<T, TKeyOfAny>
: never
export interface DefaultOptions<TError = DefaultError> {
queries?: OmitKeyof<
QueryObserverOptions<unknown, TError>,
'queryKey' | 'queryFn'
> & {
/**
* Return data in a shallow ref object (it is `false` by default). It can be set to `true` to return data in a shallow ref object, which can improve performance if your data does not need to be deeply reactive.
*/
shallow?: boolean
}
mutations?: MutationObserverOptions<unknown, TError, unknown, unknown> & {
/**
* Return data in a shallow ref object (it is `false` by default). It can be set to `true` to return data in a shallow ref object, which can improve performance if your data does not need to be deeply reactive.
*/
shallow?: boolean
}
hydrate?: HydrateOptions['defaultOptions']
dehydrate?: DehydrateOptions
}
export interface QueryClientConfig {
queryCache?: QueryCache
mutationCache?: MutationCache
defaultOptions?: DefaultOptions
}