@tanstack/solid-query 5.24.5 → 5.24.7
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-query",
|
|
3
|
-
"version": "5.24.
|
|
3
|
+
"version": "5.24.7",
|
|
4
4
|
"description": "Primitives for managing, caching and syncing asynchronous and remote data in Solid",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"solid-js": "^1.8.14",
|
|
51
|
-
"@tanstack/query-core": "5.24.
|
|
51
|
+
"@tanstack/query-core": "5.24.7"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"tsup-preset-solid": "^2.2.0",
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { describe, expectTypeOf, it } from 'vitest'
|
|
2
|
+
import { createQuery, queryOptions } from '../index'
|
|
3
|
+
|
|
4
|
+
describe('initialData', () => {
|
|
5
|
+
describe('Config object overload', () => {
|
|
6
|
+
it('TData should always be defined when initialData is provided as an object', () => {
|
|
7
|
+
const { data } = createQuery(() => ({
|
|
8
|
+
queryKey: ['key'],
|
|
9
|
+
queryFn: () => ({ wow: true }),
|
|
10
|
+
initialData: { wow: true },
|
|
11
|
+
}))
|
|
12
|
+
|
|
13
|
+
expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('TData should be defined when passed through queryOptions', () => {
|
|
17
|
+
const options = queryOptions(() => ({
|
|
18
|
+
queryKey: ['key'],
|
|
19
|
+
queryFn: () => ({ wow: true }),
|
|
20
|
+
initialData: { wow: true },
|
|
21
|
+
}))
|
|
22
|
+
const { data } = createQuery(options)
|
|
23
|
+
|
|
24
|
+
expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('TData should always be defined when initialData is provided as a function which ALWAYS returns the data', () => {
|
|
28
|
+
const { data } = createQuery(() => ({
|
|
29
|
+
queryKey: ['key'],
|
|
30
|
+
queryFn: () => ({ wow: true }),
|
|
31
|
+
initialData: () => ({ wow: true }),
|
|
32
|
+
}))
|
|
33
|
+
|
|
34
|
+
expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>()
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('TData should have undefined in the union when initialData is NOT provided', () => {
|
|
38
|
+
const { data } = createQuery(() => ({
|
|
39
|
+
queryKey: ['key'],
|
|
40
|
+
queryFn: () => ({ wow: true }),
|
|
41
|
+
}))
|
|
42
|
+
|
|
43
|
+
expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => {
|
|
47
|
+
const { data } = createQuery(() => ({
|
|
48
|
+
queryKey: ['key'],
|
|
49
|
+
queryFn: () => ({ wow: true }),
|
|
50
|
+
initialData: () => undefined as { wow: boolean } | undefined,
|
|
51
|
+
}))
|
|
52
|
+
|
|
53
|
+
expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>()
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
describe('Query key overload', () => {
|
|
58
|
+
it('TData should always be defined when initialData is provided', () => {
|
|
59
|
+
const { data } = createQuery(() => ({
|
|
60
|
+
queryKey: ['key'],
|
|
61
|
+
queryFn: () => ({ wow: true }),
|
|
62
|
+
initialData: { wow: true },
|
|
63
|
+
}))
|
|
64
|
+
|
|
65
|
+
expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>()
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('TData should have undefined in the union when initialData is NOT provided', () => {
|
|
69
|
+
const { data } = createQuery(() => ({
|
|
70
|
+
queryKey: ['key'],
|
|
71
|
+
queryFn: () => ({ wow: true }),
|
|
72
|
+
}))
|
|
73
|
+
|
|
74
|
+
expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>()
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
describe('Query key and func', () => {
|
|
79
|
+
it('TData should always be defined when initialData is provided', () => {
|
|
80
|
+
const { data } = createQuery(() => ({
|
|
81
|
+
queryKey: ['key'],
|
|
82
|
+
queryFn: () => ({ wow: true }),
|
|
83
|
+
initialData: { wow: true },
|
|
84
|
+
}))
|
|
85
|
+
|
|
86
|
+
expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>()
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('TData should have undefined in the union when initialData is NOT provided', () => {
|
|
90
|
+
const { data } = createQuery(() => ({
|
|
91
|
+
queryKey: ['key'],
|
|
92
|
+
queryFn: () => ({ wow: true }),
|
|
93
|
+
}))
|
|
94
|
+
|
|
95
|
+
expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>()
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
})
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { describe, it } from 'vitest'
|
|
2
|
-
import { createQuery, queryOptions } from '../index'
|
|
3
|
-
|
|
4
|
-
export type Equal<TTargetA, TTargetB> = (<T>() => T extends TTargetA
|
|
5
|
-
? 1
|
|
6
|
-
: 2) extends <T>() => T extends TTargetB ? 1 : 2
|
|
7
|
-
? true
|
|
8
|
-
: false
|
|
9
|
-
|
|
10
|
-
export type Expect<T extends true> = T
|
|
11
|
-
|
|
12
|
-
const doNotExecute = (_func: () => void) => true
|
|
13
|
-
|
|
14
|
-
describe('initialData', () => {
|
|
15
|
-
describe('Config object overload', () => {
|
|
16
|
-
it('TData should always be defined when initialData is provided as an object', () => {
|
|
17
|
-
doNotExecute(() => {
|
|
18
|
-
const { data } = createQuery(() => ({
|
|
19
|
-
queryKey: ['key'],
|
|
20
|
-
queryFn: () => {
|
|
21
|
-
return {
|
|
22
|
-
wow: true,
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
initialData: {
|
|
26
|
-
wow: true,
|
|
27
|
-
},
|
|
28
|
-
}))
|
|
29
|
-
|
|
30
|
-
const result: Expect<Equal<{ wow: boolean }, typeof data>> = true
|
|
31
|
-
return result
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('TData should be defined when passed through queryOptions', () => {
|
|
36
|
-
doNotExecute(() => {
|
|
37
|
-
const options = queryOptions(() => ({
|
|
38
|
-
queryKey: ['key'],
|
|
39
|
-
queryFn: () => {
|
|
40
|
-
return {
|
|
41
|
-
wow: true,
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
initialData: {
|
|
45
|
-
wow: true,
|
|
46
|
-
},
|
|
47
|
-
}))
|
|
48
|
-
const { data } = createQuery(options)
|
|
49
|
-
|
|
50
|
-
const result: Expect<Equal<{ wow: boolean }, typeof data>> = true
|
|
51
|
-
return result
|
|
52
|
-
})
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('TData should always be defined when initialData is provided as a function which ALWAYS returns the data', () => {
|
|
56
|
-
doNotExecute(() => {
|
|
57
|
-
const { data } = createQuery(() => ({
|
|
58
|
-
queryKey: ['key'],
|
|
59
|
-
queryFn: () => {
|
|
60
|
-
return {
|
|
61
|
-
wow: true,
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
initialData: () => ({
|
|
65
|
-
wow: true,
|
|
66
|
-
}),
|
|
67
|
-
}))
|
|
68
|
-
|
|
69
|
-
const result: Expect<Equal<{ wow: boolean }, typeof data>> = true
|
|
70
|
-
return result
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it('TData should have undefined in the union when initialData is NOT provided', () => {
|
|
75
|
-
doNotExecute(() => {
|
|
76
|
-
const { data } = createQuery(() => ({
|
|
77
|
-
queryKey: ['key'],
|
|
78
|
-
queryFn: () => {
|
|
79
|
-
return {
|
|
80
|
-
wow: true,
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
}))
|
|
84
|
-
|
|
85
|
-
const result: Expect<Equal<{ wow: boolean } | undefined, typeof data>> =
|
|
86
|
-
true
|
|
87
|
-
return result
|
|
88
|
-
})
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => {
|
|
92
|
-
doNotExecute(() => {
|
|
93
|
-
const { data } = createQuery(() => ({
|
|
94
|
-
queryKey: ['key'],
|
|
95
|
-
queryFn: () => {
|
|
96
|
-
return {
|
|
97
|
-
wow: true,
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
initialData: () => undefined as { wow: boolean } | undefined,
|
|
101
|
-
}))
|
|
102
|
-
|
|
103
|
-
const result: Expect<Equal<{ wow: boolean } | undefined, typeof data>> =
|
|
104
|
-
true
|
|
105
|
-
return result
|
|
106
|
-
})
|
|
107
|
-
})
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
describe('Query key overload', () => {
|
|
111
|
-
it('TData should always be defined when initialData is provided', () => {
|
|
112
|
-
doNotExecute(() => {
|
|
113
|
-
const { data } = createQuery(() => ({
|
|
114
|
-
queryKey: ['key'],
|
|
115
|
-
queryFn: () => {
|
|
116
|
-
return {
|
|
117
|
-
wow: true,
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
initialData: {
|
|
121
|
-
wow: true,
|
|
122
|
-
},
|
|
123
|
-
}))
|
|
124
|
-
|
|
125
|
-
const result: Expect<Equal<{ wow: boolean }, typeof data>> = true
|
|
126
|
-
return result
|
|
127
|
-
})
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
it('TData should have undefined in the union when initialData is NOT provided', () => {
|
|
131
|
-
doNotExecute(() => {
|
|
132
|
-
const { data } = createQuery(() => ({
|
|
133
|
-
queryKey: ['key'],
|
|
134
|
-
queryFn: () => {
|
|
135
|
-
return {
|
|
136
|
-
wow: true,
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
}))
|
|
140
|
-
|
|
141
|
-
const result: Expect<Equal<{ wow: boolean } | undefined, typeof data>> =
|
|
142
|
-
true
|
|
143
|
-
return result
|
|
144
|
-
})
|
|
145
|
-
})
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
describe('Query key and func', () => {
|
|
149
|
-
it('TData should always be defined when initialData is provided', () => {
|
|
150
|
-
doNotExecute(() => {
|
|
151
|
-
const { data } = createQuery(() => ({
|
|
152
|
-
queryKey: ['key'],
|
|
153
|
-
queryFn: () => {
|
|
154
|
-
return {
|
|
155
|
-
wow: true,
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
initialData: {
|
|
160
|
-
wow: true,
|
|
161
|
-
},
|
|
162
|
-
}))
|
|
163
|
-
|
|
164
|
-
const result: Expect<Equal<{ wow: boolean }, typeof data>> = true
|
|
165
|
-
return result
|
|
166
|
-
})
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
it('TData should have undefined in the union when initialData is NOT provided', () => {
|
|
170
|
-
doNotExecute(() => {
|
|
171
|
-
const { data } = createQuery(() => ({
|
|
172
|
-
queryKey: ['key'],
|
|
173
|
-
queryFn: () => {
|
|
174
|
-
return {
|
|
175
|
-
wow: true,
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
}))
|
|
179
|
-
|
|
180
|
-
const result: Expect<Equal<{ wow: boolean } | undefined, typeof data>> =
|
|
181
|
-
true
|
|
182
|
-
return result
|
|
183
|
-
})
|
|
184
|
-
})
|
|
185
|
-
})
|
|
186
|
-
})
|