@tanstack/react-query 5.14.6 → 5.15.0

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/react-query",
3
- "version": "5.14.6",
3
+ "version": "5.15.0",
4
4
  "description": "Hooks for managing, caching and syncing asynchronous and remote data in React",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -101,64 +101,61 @@ describe('queryOptions', () => {
101
101
  > = true
102
102
  return result
103
103
  })
104
-
105
- it('should tag the queryKey even if no promise is returned', () => {
106
- doNotExecute(() => {
107
- const { queryKey } = infiniteQueryOptions({
108
- queryKey: ['key'],
109
- queryFn: () => 'string',
110
- getNextPageParam: () => 1,
111
- initialPageParam: 1,
112
- })
113
-
114
- const result: Expect<
115
- Equal<(typeof queryKey)[typeof dataTagSymbol], InfiniteData<string>>
116
- > = true
117
- return result
104
+ })
105
+ it('should tag the queryKey even if no promise is returned', () => {
106
+ doNotExecute(() => {
107
+ const { queryKey } = infiniteQueryOptions({
108
+ queryKey: ['key'],
109
+ queryFn: () => 'string',
110
+ getNextPageParam: () => 1,
111
+ initialPageParam: 1,
118
112
  })
119
- })
120
-
121
- it('should return the proper type when passed to getQueryData', () => {
122
- doNotExecute(() => {
123
- const { queryKey } = infiniteQueryOptions({
124
- queryKey: ['key'],
125
- queryFn: () => Promise.resolve('string'),
126
- getNextPageParam: () => 1,
127
- initialPageParam: 1,
128
- })
129
113
 
130
- const queryClient = new QueryClient()
131
- const data = queryClient.getQueryData(queryKey)
132
-
133
- const result: Expect<
134
- Equal<typeof data, InfiniteData<string, unknown> | undefined>
135
- > = true
136
- return result
137
- })
114
+ const result: Expect<
115
+ Equal<(typeof queryKey)[typeof dataTagSymbol], InfiniteData<string>>
116
+ > = true
117
+ return result
138
118
  })
119
+ })
120
+ it('should return the proper type when passed to getQueryData', () => {
121
+ doNotExecute(() => {
122
+ const { queryKey } = infiniteQueryOptions({
123
+ queryKey: ['key'],
124
+ queryFn: () => Promise.resolve('string'),
125
+ getNextPageParam: () => 1,
126
+ initialPageParam: 1,
127
+ })
139
128
 
140
- it('should properly type when passed to setQueryData', () => {
141
- doNotExecute(() => {
142
- const { queryKey } = infiniteQueryOptions({
143
- queryKey: ['key'],
144
- queryFn: () => Promise.resolve('string'),
145
- getNextPageParam: () => 1,
146
- initialPageParam: 1,
147
- })
129
+ const queryClient = new QueryClient()
130
+ const data = queryClient.getQueryData(queryKey)
148
131
 
149
- const queryClient = new QueryClient()
150
- const data = queryClient.setQueryData(queryKey, (prev) => {
151
- const result: Expect<
152
- Equal<typeof prev, InfiniteData<string, unknown> | undefined>
153
- > = true
154
- return result ? prev : { pages: ['foo'], pageParams: [1] }
155
- })
132
+ const result: Expect<
133
+ Equal<typeof data, InfiniteData<string, unknown> | undefined>
134
+ > = true
135
+ return result
136
+ })
137
+ })
138
+ it('should properly type when passed to setQueryData', () => {
139
+ doNotExecute(() => {
140
+ const { queryKey } = infiniteQueryOptions({
141
+ queryKey: ['key'],
142
+ queryFn: () => Promise.resolve('string'),
143
+ getNextPageParam: () => 1,
144
+ initialPageParam: 1,
145
+ })
156
146
 
147
+ const queryClient = new QueryClient()
148
+ const data = queryClient.setQueryData(queryKey, (prev) => {
157
149
  const result: Expect<
158
- Equal<typeof data, InfiniteData<string, unknown> | undefined>
150
+ Equal<typeof prev, InfiniteData<string, unknown> | undefined>
159
151
  > = true
160
- return result
152
+ return result ? prev : { pages: ['foo'], pageParams: [1] }
161
153
  })
154
+
155
+ const result: Expect<
156
+ Equal<typeof data, InfiniteData<string, unknown> | undefined>
157
+ > = true
158
+ return result
162
159
  })
163
160
  })
164
161
  })
@@ -98,86 +98,81 @@ describe('queryOptions', () => {
98
98
  > = true
99
99
  return result
100
100
  })
101
-
102
- it('should tag the queryKey even if no promise is returned', () => {
103
- doNotExecute(() => {
104
- const { queryKey } = queryOptions({
105
- queryKey: ['key'],
106
- queryFn: () => 5,
107
- })
108
-
109
- const result: Expect<
110
- Equal<(typeof queryKey)[typeof dataTagSymbol], number>
111
- > = true
112
- return result
101
+ })
102
+ it('should tag the queryKey even if no promise is returned', () => {
103
+ doNotExecute(() => {
104
+ const { queryKey } = queryOptions({
105
+ queryKey: ['key'],
106
+ queryFn: () => 5,
113
107
  })
114
- })
115
-
116
- it('should tag the queryKey with unknown if there is no queryFn', () => {
117
- doNotExecute(() => {
118
- const { queryKey } = queryOptions({
119
- queryKey: ['key'],
120
- })
121
108
 
122
- const result: Expect<
123
- Equal<(typeof queryKey)[typeof dataTagSymbol], unknown>
124
- > = true
125
- return result
126
- })
109
+ const result: Expect<
110
+ Equal<(typeof queryKey)[typeof dataTagSymbol], number>
111
+ > = true
112
+ return result
127
113
  })
114
+ })
115
+ it('should tag the queryKey with unknown if there is no queryFn', () => {
116
+ doNotExecute(() => {
117
+ const { queryKey } = queryOptions({
118
+ queryKey: ['key'],
119
+ })
128
120
 
129
- it('should return the proper type when passed to getQueryData', () => {
130
- doNotExecute(() => {
131
- const { queryKey } = queryOptions({
132
- queryKey: ['key'],
133
- queryFn: () => Promise.resolve(5),
134
- })
121
+ const result: Expect<
122
+ Equal<(typeof queryKey)[typeof dataTagSymbol], unknown>
123
+ > = true
124
+ return result
125
+ })
126
+ })
127
+ it('should return the proper type when passed to getQueryData', () => {
128
+ doNotExecute(() => {
129
+ const { queryKey } = queryOptions({
130
+ queryKey: ['key'],
131
+ queryFn: () => Promise.resolve(5),
132
+ })
135
133
 
136
- const queryClient = new QueryClient()
137
- const data = queryClient.getQueryData(queryKey)
134
+ const queryClient = new QueryClient()
135
+ const data = queryClient.getQueryData(queryKey)
138
136
 
139
- const result: Expect<Equal<typeof data, number | undefined>> = true
140
- return result
141
- })
137
+ const result: Expect<Equal<typeof data, number | undefined>> = true
138
+ return result
142
139
  })
140
+ })
141
+ it('should properly type updaterFn when passed to setQueryData', () => {
142
+ doNotExecute(() => {
143
+ const { queryKey } = queryOptions({
144
+ queryKey: ['key'],
145
+ queryFn: () => Promise.resolve(5),
146
+ })
143
147
 
144
- it('should properly type updaterFn when passed to setQueryData', () => {
145
- doNotExecute(() => {
146
- const { queryKey } = queryOptions({
147
- queryKey: ['key'],
148
- queryFn: () => Promise.resolve(5),
149
- })
150
-
151
- const queryClient = new QueryClient()
152
- const data = queryClient.setQueryData(queryKey, (prev) => {
153
- const result: Expect<Equal<typeof prev, number | undefined>> = true
154
- return result ? prev : 1
155
- })
156
-
157
- const result: Expect<Equal<typeof data, number | undefined>> = true
158
- return result
148
+ const queryClient = new QueryClient()
149
+ const data = queryClient.setQueryData(queryKey, (prev) => {
150
+ const result: Expect<Equal<typeof prev, number | undefined>> = true
151
+ return result ? prev : 1
159
152
  })
160
- })
161
153
 
162
- it('should properly type value when passed to setQueryData', () => {
163
- doNotExecute(() => {
164
- const { queryKey } = queryOptions({
165
- queryKey: ['key'],
166
- queryFn: () => Promise.resolve(5),
167
- })
154
+ const result: Expect<Equal<typeof data, number | undefined>> = true
155
+ return result
156
+ })
157
+ })
158
+ it('should properly type value when passed to setQueryData', () => {
159
+ doNotExecute(() => {
160
+ const { queryKey } = queryOptions({
161
+ queryKey: ['key'],
162
+ queryFn: () => Promise.resolve(5),
163
+ })
168
164
 
169
- const queryClient = new QueryClient()
165
+ const queryClient = new QueryClient()
170
166
 
171
- // @ts-expect-error value should be a number
172
- queryClient.setQueryData(queryKey, '5')
173
- // @ts-expect-error value should be a number
174
- queryClient.setQueryData(queryKey, () => '5')
167
+ // @ts-expect-error value should be a number
168
+ queryClient.setQueryData(queryKey, '5')
169
+ // @ts-expect-error value should be a number
170
+ queryClient.setQueryData(queryKey, () => '5')
175
171
 
176
- const data = queryClient.setQueryData(queryKey, 5)
172
+ const data = queryClient.setQueryData(queryKey, 5)
177
173
 
178
- const result: Expect<Equal<typeof data, number | undefined>> = true
179
- return result
180
- })
174
+ const result: Expect<Equal<typeof data, number | undefined>> = true
175
+ return result
181
176
  })
182
177
  })
183
178
  })