@tanstack/query-core 5.17.14 → 5.17.19
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/legacy/hydration.d.cts +1 -1
- package/build/legacy/hydration.d.ts +1 -1
- package/build/legacy/index.d.cts +1 -1
- package/build/legacy/index.d.ts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.cts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.ts +1 -1
- package/build/legacy/infiniteQueryObserver.d.cts +1 -1
- package/build/legacy/infiniteQueryObserver.d.ts +1 -1
- package/build/legacy/mutation.d.cts +1 -1
- package/build/legacy/mutation.d.ts +1 -1
- package/build/legacy/mutationCache.d.cts +1 -1
- package/build/legacy/mutationCache.d.ts +1 -1
- package/build/legacy/mutationObserver.d.cts +1 -1
- package/build/legacy/mutationObserver.d.ts +1 -1
- package/build/legacy/queriesObserver.d.cts +1 -1
- package/build/legacy/queriesObserver.d.ts +1 -1
- package/build/legacy/query.d.cts +1 -1
- package/build/legacy/query.d.ts +1 -1
- package/build/legacy/queryCache.d.cts +1 -1
- package/build/legacy/queryCache.d.ts +1 -1
- package/build/legacy/{queryClient-4iFPaIys.d.cts → queryClient-Z9CwNwtC.d.cts} +1 -1
- package/build/legacy/{queryClient-4ddEge6Q.d.ts → queryClient-aPcvMwE9.d.ts} +1 -1
- package/build/legacy/queryClient.d.cts +1 -1
- package/build/legacy/queryClient.d.ts +1 -1
- package/build/legacy/queryObserver.d.cts +1 -1
- package/build/legacy/queryObserver.d.ts +1 -1
- package/build/legacy/retryer.d.cts +1 -1
- package/build/legacy/retryer.d.ts +1 -1
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +1 -1
- package/build/legacy/types.d.ts +1 -1
- package/build/legacy/utils.cjs +9 -3
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.d.cts +1 -1
- package/build/legacy/utils.d.ts +1 -1
- package/build/legacy/utils.js +9 -3
- package/build/legacy/utils.js.map +1 -1
- package/build/modern/hydration.d.cts +1 -1
- package/build/modern/hydration.d.ts +1 -1
- package/build/modern/index.d.cts +1 -1
- package/build/modern/index.d.ts +1 -1
- package/build/modern/infiniteQueryBehavior.d.cts +1 -1
- package/build/modern/infiniteQueryBehavior.d.ts +1 -1
- package/build/modern/infiniteQueryObserver.d.cts +1 -1
- package/build/modern/infiniteQueryObserver.d.ts +1 -1
- package/build/modern/mutation.d.cts +1 -1
- package/build/modern/mutation.d.ts +1 -1
- package/build/modern/mutationCache.d.cts +1 -1
- package/build/modern/mutationCache.d.ts +1 -1
- package/build/modern/mutationObserver.d.cts +1 -1
- package/build/modern/mutationObserver.d.ts +1 -1
- package/build/modern/queriesObserver.d.cts +1 -1
- package/build/modern/queriesObserver.d.ts +1 -1
- package/build/modern/query.d.cts +1 -1
- package/build/modern/query.d.ts +1 -1
- package/build/modern/queryCache.d.cts +1 -1
- package/build/modern/queryCache.d.ts +1 -1
- package/build/modern/{queryClient-4iFPaIys.d.cts → queryClient-Z9CwNwtC.d.cts} +1 -1
- package/build/modern/{queryClient-4ddEge6Q.d.ts → queryClient-aPcvMwE9.d.ts} +1 -1
- package/build/modern/queryClient.d.cts +1 -1
- package/build/modern/queryClient.d.ts +1 -1
- package/build/modern/queryObserver.d.cts +1 -1
- package/build/modern/queryObserver.d.ts +1 -1
- package/build/modern/retryer.d.cts +1 -1
- package/build/modern/retryer.d.ts +1 -1
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +1 -1
- package/build/modern/types.d.ts +1 -1
- package/build/modern/utils.cjs +9 -3
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.d.cts +1 -1
- package/build/modern/utils.d.ts +1 -1
- package/build/modern/utils.js +9 -3
- package/build/modern/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/tests/utils.test.tsx +18 -0
- package/src/types.ts +3 -1
- package/src/utils.ts +14 -3
package/src/tests/utils.test.tsx
CHANGED
|
@@ -332,6 +332,24 @@ describe('core/utils', () => {
|
|
|
332
332
|
const result = replaceEqualDeep(obj1, obj2)
|
|
333
333
|
expect(result).toStrictEqual(obj2)
|
|
334
334
|
})
|
|
335
|
+
|
|
336
|
+
it('should be able to share values that contain undefined', () => {
|
|
337
|
+
const current = [
|
|
338
|
+
{
|
|
339
|
+
data: undefined,
|
|
340
|
+
foo: true,
|
|
341
|
+
},
|
|
342
|
+
]
|
|
343
|
+
|
|
344
|
+
const next = replaceEqualDeep(current, [
|
|
345
|
+
{
|
|
346
|
+
data: undefined,
|
|
347
|
+
foo: true,
|
|
348
|
+
},
|
|
349
|
+
])
|
|
350
|
+
|
|
351
|
+
expect(current).toBe(next)
|
|
352
|
+
})
|
|
335
353
|
})
|
|
336
354
|
|
|
337
355
|
describe('matchMutation', () => {
|
package/src/types.ts
CHANGED
|
@@ -688,7 +688,9 @@ export type MutationStatus = 'idle' | 'pending' | 'success' | 'error'
|
|
|
688
688
|
export type MutationMeta = Register extends {
|
|
689
689
|
mutationMeta: infer TMutationMeta
|
|
690
690
|
}
|
|
691
|
-
? TMutationMeta
|
|
691
|
+
? TMutationMeta extends Record<string, unknown>
|
|
692
|
+
? TMutationMeta
|
|
693
|
+
: Record<string, unknown>
|
|
692
694
|
: Record<string, unknown>
|
|
693
695
|
|
|
694
696
|
export type MutationFunction<TData = unknown, TVariables = unknown> = (
|
package/src/utils.ts
CHANGED
|
@@ -224,7 +224,8 @@ export function replaceEqualDeep(a: any, b: any): any {
|
|
|
224
224
|
const array = isPlainArray(a) && isPlainArray(b)
|
|
225
225
|
|
|
226
226
|
if (array || (isPlainObject(a) && isPlainObject(b))) {
|
|
227
|
-
const
|
|
227
|
+
const aItems = array ? a : Object.keys(a)
|
|
228
|
+
const aSize = aItems.length
|
|
228
229
|
const bItems = array ? b : Object.keys(b)
|
|
229
230
|
const bSize = bItems.length
|
|
230
231
|
const copy: any = array ? [] : {}
|
|
@@ -233,9 +234,19 @@ export function replaceEqualDeep(a: any, b: any): any {
|
|
|
233
234
|
|
|
234
235
|
for (let i = 0; i < bSize; i++) {
|
|
235
236
|
const key = array ? i : bItems[i]
|
|
236
|
-
|
|
237
|
-
|
|
237
|
+
if (
|
|
238
|
+
!array &&
|
|
239
|
+
a[key] === undefined &&
|
|
240
|
+
b[key] === undefined &&
|
|
241
|
+
aItems.includes(key)
|
|
242
|
+
) {
|
|
243
|
+
copy[key] = undefined
|
|
238
244
|
equalItems++
|
|
245
|
+
} else {
|
|
246
|
+
copy[key] = replaceEqualDeep(a[key], b[key])
|
|
247
|
+
if (copy[key] === a[key] && a[key] !== undefined) {
|
|
248
|
+
equalItems++
|
|
249
|
+
}
|
|
239
250
|
}
|
|
240
251
|
}
|
|
241
252
|
|