@tanstack/solid-query 5.0.0-beta.17 → 5.0.0-beta.20
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/build/index.d.cts +3 -3
- package/build/index.d.ts +3 -3
- package/package.json +2 -2
- package/src/__tests__/createInfiniteQuery.test.tsx +59 -52
- package/src/__tests__/createMutation.test.tsx +4 -4
- package/src/__tests__/createQueries.test.tsx +30 -28
- package/src/__tests__/createQuery.test.tsx +74 -72
- package/src/__tests__/suspense.test.tsx +5 -5
- package/src/__tests__/useIsFetching.test.tsx +2 -2
- package/src/__tests__/useIsMutating.test.tsx +3 -3
- package/src/createQueries.ts +35 -27
- package/src/utils.ts +1 -1
|
@@ -8,7 +8,7 @@ import { createQueryClient, setActTimeout, sleep } from './utils'
|
|
|
8
8
|
|
|
9
9
|
describe('useIsMutating', () => {
|
|
10
10
|
it('should return the number of fetching mutations', async () => {
|
|
11
|
-
const isMutatings: number
|
|
11
|
+
const isMutatings: Array<number> = []
|
|
12
12
|
const queryClient = createQueryClient()
|
|
13
13
|
|
|
14
14
|
function IsMutating() {
|
|
@@ -63,7 +63,7 @@ describe('useIsMutating', () => {
|
|
|
63
63
|
})
|
|
64
64
|
|
|
65
65
|
it('should filter correctly by mutationKey', async () => {
|
|
66
|
-
const isMutatings: number
|
|
66
|
+
const isMutatings: Array<number> = []
|
|
67
67
|
const queryClient = createQueryClient()
|
|
68
68
|
|
|
69
69
|
function IsMutating() {
|
|
@@ -108,7 +108,7 @@ describe('useIsMutating', () => {
|
|
|
108
108
|
})
|
|
109
109
|
|
|
110
110
|
it('should filter correctly by predicate', async () => {
|
|
111
|
-
const isMutatings: number
|
|
111
|
+
const isMutatings: Array<number> = []
|
|
112
112
|
const queryClient = createQueryClient()
|
|
113
113
|
|
|
114
114
|
function IsMutating() {
|
package/src/createQueries.ts
CHANGED
|
@@ -95,62 +95,70 @@ type GetResults<T> =
|
|
|
95
95
|
* QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param
|
|
96
96
|
*/
|
|
97
97
|
export type QueriesOptions<
|
|
98
|
-
T extends any
|
|
99
|
-
Result extends any
|
|
98
|
+
T extends Array<any>,
|
|
99
|
+
Result extends Array<any> = [],
|
|
100
100
|
Depth extends ReadonlyArray<number> = [],
|
|
101
101
|
> = Depth['length'] extends MAXIMUM_DEPTH
|
|
102
|
-
? CreateQueryOptionsForCreateQueries
|
|
102
|
+
? Array<CreateQueryOptionsForCreateQueries>
|
|
103
103
|
: T extends []
|
|
104
104
|
? []
|
|
105
105
|
: T extends [infer Head]
|
|
106
106
|
? [...Result, GetOptions<Head>]
|
|
107
107
|
: T extends [infer Head, ...infer Tail]
|
|
108
108
|
? QueriesOptions<[...Tail], [...Result, GetOptions<Head>], [...Depth, 1]>
|
|
109
|
-
: unknown
|
|
109
|
+
: Array<unknown> extends T
|
|
110
110
|
? T
|
|
111
111
|
: // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogenous type!
|
|
112
112
|
// use this to infer the param types in the case of Array.map() argument
|
|
113
|
-
T extends
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
T extends Array<
|
|
114
|
+
CreateQueryOptionsForCreateQueries<
|
|
115
|
+
infer TQueryFnData,
|
|
116
|
+
infer TError,
|
|
117
|
+
infer TData,
|
|
118
|
+
infer TQueryKey
|
|
119
|
+
>
|
|
120
|
+
>
|
|
121
|
+
? Array<
|
|
122
|
+
CreateQueryOptionsForCreateQueries<TQueryFnData, TError, TData, TQueryKey>
|
|
123
|
+
>
|
|
120
124
|
: // Fallback
|
|
121
|
-
CreateQueryOptionsForCreateQueries
|
|
125
|
+
Array<CreateQueryOptionsForCreateQueries>
|
|
122
126
|
|
|
123
127
|
/**
|
|
124
128
|
* QueriesResults reducer recursively maps type param to results
|
|
125
129
|
*/
|
|
126
130
|
export type QueriesResults<
|
|
127
|
-
T extends any
|
|
128
|
-
Result extends any
|
|
131
|
+
T extends Array<any>,
|
|
132
|
+
Result extends Array<any> = [],
|
|
129
133
|
Depth extends ReadonlyArray<number> = [],
|
|
130
134
|
> = Depth['length'] extends MAXIMUM_DEPTH
|
|
131
|
-
? CreateQueryResult
|
|
135
|
+
? Array<CreateQueryResult>
|
|
132
136
|
: T extends []
|
|
133
137
|
? []
|
|
134
138
|
: T extends [infer Head]
|
|
135
139
|
? [...Result, GetResults<Head>]
|
|
136
140
|
: T extends [infer Head, ...infer Tail]
|
|
137
141
|
? QueriesResults<[...Tail], [...Result, GetResults<Head>], [...Depth, 1]>
|
|
138
|
-
: T extends
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
: T extends Array<
|
|
143
|
+
CreateQueryOptionsForCreateQueries<
|
|
144
|
+
infer TQueryFnData,
|
|
145
|
+
infer TError,
|
|
146
|
+
infer TData,
|
|
147
|
+
any
|
|
148
|
+
>
|
|
149
|
+
>
|
|
144
150
|
? // Dynamic-size (homogenous) UseQueryOptions array: map directly to array of results
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
151
|
+
Array<
|
|
152
|
+
CreateQueryResult<
|
|
153
|
+
unknown extends TData ? TQueryFnData : TData,
|
|
154
|
+
unknown extends TError ? DefaultError : TError
|
|
155
|
+
>
|
|
156
|
+
>
|
|
149
157
|
: // Fallback
|
|
150
|
-
CreateQueryResult
|
|
158
|
+
Array<CreateQueryResult>
|
|
151
159
|
|
|
152
160
|
export function createQueries<
|
|
153
|
-
T extends any
|
|
161
|
+
T extends Array<any>,
|
|
154
162
|
TCombinedResult = QueriesResults<T>,
|
|
155
163
|
>(
|
|
156
164
|
queriesOptions: Accessor<{
|
package/src/utils.ts
CHANGED