From 747aa781496f054f7103ec440d51342fdfaa5382 Mon Sep 17 00:00:00 2001 From: SebKranz <33868262+SebKranz@users.noreply.github.com> Date: Sat, 24 Feb 2024 13:54:00 +0100 Subject: [PATCH 01/10] test(queryClient): Remove flaky perfomance tests (#6946) --- .../query-core/src/tests/queryClient.test.tsx | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/packages/query-core/src/tests/queryClient.test.tsx b/packages/query-core/src/tests/queryClient.test.tsx index 66a485d93e..79e77892ec 100644 --- a/packages/query-core/src/tests/queryClient.test.tsx +++ b/packages/query-core/src/tests/queryClient.test.tsx @@ -356,16 +356,6 @@ describe('queryClient', () => { }), ) }) - - test('should set 10k data in less than 500ms', () => { - const key = queryKey() - const start = performance.now() - for (let i = 0; i < 10000; i++) { - queryClient.setQueryData([key, i], i) - } - const end = performance.now() - expect(end - start).toBeLessThan(500) - }) }) describe('setQueriesData', () => { @@ -429,38 +419,6 @@ describe('queryClient', () => { queryClient.setQueryData([key, 'id'], 'bar') expect(queryClient.getQueryData([key])).toBeUndefined() }) - - test('should get 10k queries in less than 500ms', () => { - const key = queryKey() - for (let i = 0; i < 10000; i++) { - queryClient.setQueryData([key, i], i) - } - - const start = performance.now() - for (let i = 0; i < 10000; i++) { - queryClient.getQueryData([key, i]) - } - const end = performance.now() - - expect(end - start).toBeLessThan(500) - }) - }) - - describe('getQueryState', () => { - test('should get 10k queries in less than 500ms', () => { - const key = queryKey() - for (let i = 0; i < 10000; i++) { - queryClient.setQueryData([key, i], i) - } - - const start = performance.now() - for (let i = 0; i < 10000; i++) { - queryClient.getQueryState([key, i]) - } - const end = performance.now() - - expect(end - start).toBeLessThan(500) - }) }) describe('ensureQueryData', () => { From 3de4859b3a5230d7ce0c96755340ca8a934cd7b6 Mon Sep 17 00:00:00 2001 From: Riccardo Perra Date: Sun, 25 Feb 2024 01:48:15 +0100 Subject: [PATCH 02/10] fix(angular-query): fix NG0602 error (#6966) * fix(angular-query): fix NG0602 error * chore: run prettier on PR --------- Co-authored-by: Arnoud de Vries <6420061+arnoud-dv@users.noreply.github.com> --- .../src/create-base-query.ts | 25 +++++++++++-------- .../src/lazy-init.ts | 4 +-- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/angular-query-experimental/src/create-base-query.ts b/packages/angular-query-experimental/src/create-base-query.ts index b7a2299dab..a6685da626 100644 --- a/packages/angular-query-experimental/src/create-base-query.ts +++ b/packages/angular-query-experimental/src/create-base-query.ts @@ -67,17 +67,20 @@ export function createBaseQuery< observer.getOptimisticResult(defaultedOptionsSignal()), ) - effect(() => { - const defaultedOptions = defaultedOptionsSignal() - observer.setOptions(defaultedOptions, { - // Do not notify on updates because of changes in the options because - // these changes should already be reflected in the optimistic result. - listeners: false, - }) - untracked(() => { - resultSignal.set(observer.getOptimisticResult(defaultedOptions)) - }) - }) + // Effects should not be called inside reactive contexts + untracked(() => + effect(() => { + const defaultedOptions = defaultedOptionsSignal() + observer.setOptions(defaultedOptions, { + // Do not notify on updates because of changes in the options because + // these changes should already be reflected in the optimistic result. + listeners: false, + }) + untracked(() => { + resultSignal.set(observer.getOptimisticResult(defaultedOptions)) + }) + }), + ) // observer.trackResult is not used as this optimization is not needed for Angular const unsubscribe = observer.subscribe( diff --git a/packages/angular-query-experimental/src/lazy-init.ts b/packages/angular-query-experimental/src/lazy-init.ts index 8c8fc4143d..86b2a6f0ca 100644 --- a/packages/angular-query-experimental/src/lazy-init.ts +++ b/packages/angular-query-experimental/src/lazy-init.ts @@ -7,9 +7,7 @@ export function lazyInit(initializer: () => T): T { } } - Promise.resolve().then(() => { - initializeObject() - }) + queueMicrotask(() => initializeObject()) return new Proxy({} as T, { get(_, prop, receiver) { From 97b013a53d6a0fc77412d6272d03d4cf4a576100 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Sun, 25 Feb 2024 00:53:25 +0000 Subject: [PATCH 03/10] release: v5.24.1 --- examples/angular/basic/package.json | 4 +- .../package.json | 4 +- examples/angular/router/package.json | 4 +- examples/angular/simple/package.json | 4 +- examples/react/algolia/package.json | 4 +- examples/react/auto-refetching/package.json | 4 +- .../react/basic-graphql-request/package.json | 4 +- examples/react/basic-typescript/package.json | 8 +- examples/react/basic/package.json | 4 +- .../react/default-query-function/package.json | 4 +- .../package.json | 4 +- .../load-more-infinite-scroll/package.json | 4 +- .../nextjs-suspense-streaming/package.json | 6 +- examples/react/nextjs/package.json | 4 +- examples/react/offline/package.json | 8 +- .../optimistic-updates-cache/package.json | 4 +- .../react/optimistic-updates-ui/package.json | 4 +- examples/react/pagination/package.json | 4 +- examples/react/playground/package.json | 4 +- examples/react/prefetching/package.json | 4 +- examples/react/react-native/package.json | 4 +- examples/react/react-router/package.json | 4 +- examples/react/rick-morty/package.json | 4 +- examples/react/simple/package.json | 4 +- examples/react/star-wars/package.json | 4 +- examples/react/suspense/package.json | 4 +- .../solid/basic-graphql-request/package.json | 4 +- examples/solid/basic-typescript/package.json | 4 +- .../solid/default-query-function/package.json | 4 +- examples/solid/simple/package.json | 4 +- .../solid/solid-start-streaming/package.json | 4 +- examples/svelte/auto-refetching/package.json | 4 +- examples/svelte/basic/package.json | 4 +- .../load-more-infinite-scroll/package.json | 4 +- .../package.json | 4 +- examples/svelte/playground/package.json | 4 +- examples/svelte/simple/package.json | 4 +- examples/svelte/ssr/package.json | 4 +- examples/svelte/star-wars/package.json | 4 +- examples/vue/2.6-basic/package.json | 2 +- examples/vue/basic/package.json | 4 +- examples/vue/dependent-queries/package.json | 2 +- examples/vue/nuxt3/package.json | 2 +- examples/vue/persister/package.json | 8 +- examples/vue/simple/package.json | 4 +- .../package.json | 2 +- .../angular-query-experimental/package.json | 2 +- .../package.json | 2 +- .../package.json | 2 +- packages/query-core/package.json | 2 +- .../query-persist-client-core/package.json | 2 +- .../query-sync-storage-persister/package.json | 2 +- packages/react-query-devtools/package.json | 2 +- .../package.json | 2 +- .../react-query-persist-client/package.json | 2 +- packages/react-query/package.json | 2 +- packages/solid-query-devtools/package.json | 2 +- .../solid-query-persist-client/package.json | 2 +- packages/solid-query/package.json | 2 +- packages/svelte-query-devtools/package.json | 2 +- .../svelte-query-persist-client/package.json | 2 +- packages/svelte-query/package.json | 2 +- packages/vue-query-devtools/package.json | 2 +- packages/vue-query/package.json | 2 +- pnpm-lock.yaml | 184 +++++++++--------- 65 files changed, 205 insertions(+), 205 deletions(-) diff --git a/examples/angular/basic/package.json b/examples/angular/basic/package.json index e4f3c27252..de6fa1ec9f 100644 --- a/examples/angular/basic/package.json +++ b/examples/angular/basic/package.json @@ -17,7 +17,7 @@ "@angular/platform-browser": "^17.1.3", "@angular/platform-browser-dynamic": "^17.1.3", "@angular/router": "^17.1.3", - "@tanstack/angular-query-experimental": "^5.22.2", + "@tanstack/angular-query-experimental": "^5.24.1", "rxjs": "^7.8.1", "tslib": "^2.6.2", "zone.js": "^0.14.3" @@ -26,7 +26,7 @@ "@angular-devkit/build-angular": "^17.1.3", "@angular/cli": "^17.1.3", "@angular/compiler-cli": "^17.1.3", - "@tanstack/angular-query-devtools-experimental": "^5.24.0", + "@tanstack/angular-query-devtools-experimental": "^5.24.1", "typescript": "5.2.2" }, "overrides": { diff --git a/examples/angular/infinite-query-with-max-pages/package.json b/examples/angular/infinite-query-with-max-pages/package.json index 5a2d3ebacc..7a82323ec3 100644 --- a/examples/angular/infinite-query-with-max-pages/package.json +++ b/examples/angular/infinite-query-with-max-pages/package.json @@ -17,7 +17,7 @@ "@angular/platform-browser": "^17.1.3", "@angular/platform-browser-dynamic": "^17.1.3", "@angular/router": "^17.1.3", - "@tanstack/angular-query-experimental": "^5.22.2", + "@tanstack/angular-query-experimental": "^5.24.1", "rxjs": "^7.8.1", "tslib": "^2.6.2", "zone.js": "^0.14.3" @@ -26,7 +26,7 @@ "@angular-devkit/build-angular": "^17.1.3", "@angular/cli": "^17.1.3", "@angular/compiler-cli": "^17.1.3", - "@tanstack/angular-query-devtools-experimental": "^5.24.0", + "@tanstack/angular-query-devtools-experimental": "^5.24.1", "typescript": "5.2.2" }, "overrides": { diff --git a/examples/angular/router/package.json b/examples/angular/router/package.json index 8bfbbc55d7..124cb14a9b 100644 --- a/examples/angular/router/package.json +++ b/examples/angular/router/package.json @@ -17,7 +17,7 @@ "@angular/platform-browser": "^17.1.3", "@angular/platform-browser-dynamic": "^17.1.3", "@angular/router": "^17.1.3", - "@tanstack/angular-query-experimental": "^5.22.2", + "@tanstack/angular-query-experimental": "^5.24.1", "rxjs": "^7.8.1", "tslib": "^2.6.2", "zone.js": "^0.14.3" @@ -26,7 +26,7 @@ "@angular-devkit/build-angular": "^17.1.3", "@angular/cli": "^17.1.3", "@angular/compiler-cli": "^17.1.3", - "@tanstack/angular-query-devtools-experimental": "^5.24.0", + "@tanstack/angular-query-devtools-experimental": "^5.24.1", "typescript": "5.2.2" }, "overrides": { diff --git a/examples/angular/simple/package.json b/examples/angular/simple/package.json index 85fe5a5adc..c4bcc7dad1 100644 --- a/examples/angular/simple/package.json +++ b/examples/angular/simple/package.json @@ -17,7 +17,7 @@ "@angular/platform-browser": "^17.1.3", "@angular/platform-browser-dynamic": "^17.1.3", "@angular/router": "^17.1.3", - "@tanstack/angular-query-experimental": "^5.22.2", + "@tanstack/angular-query-experimental": "^5.24.1", "rxjs": "^7.8.1", "tslib": "^2.6.2", "zone.js": "^0.14.3" @@ -26,7 +26,7 @@ "@angular-devkit/build-angular": "^17.1.3", "@angular/cli": "^17.1.3", "@angular/compiler-cli": "^17.1.3", - "@tanstack/angular-query-devtools-experimental": "^5.24.0", + "@tanstack/angular-query-devtools-experimental": "^5.24.1", "typescript": "5.2.2" }, "overrides": { diff --git a/examples/react/algolia/package.json b/examples/react/algolia/package.json index 03c13e4eeb..f9cffd122b 100644 --- a/examples/react/algolia/package.json +++ b/examples/react/algolia/package.json @@ -11,8 +11,8 @@ "dependencies": { "@algolia/client-search": "4.22.1", "@algolia/transporter": "4.22.1", - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "algoliasearch": "4.22.1", "react": "^18.2.0", "react-dom": "^18.2.0" diff --git a/examples/react/auto-refetching/package.json b/examples/react/auto-refetching/package.json index 0ae0be9821..41280eddc5 100644 --- a/examples/react/auto-refetching/package.json +++ b/examples/react/auto-refetching/package.json @@ -7,8 +7,8 @@ "start": "next start" }, "dependencies": { - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "axios": "^1.6.7", "isomorphic-unfetch": "4.0.2", "next": "^14.0.0", diff --git a/examples/react/basic-graphql-request/package.json b/examples/react/basic-graphql-request/package.json index 71aee4cba4..fb26ed2bf2 100644 --- a/examples/react/basic-graphql-request/package.json +++ b/examples/react/basic-graphql-request/package.json @@ -8,8 +8,8 @@ "preview": "vite preview" }, "dependencies": { - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "graphql": "^16.8.1", "graphql-request": "^6.1.0", "react": "^18.2.0", diff --git a/examples/react/basic-typescript/package.json b/examples/react/basic-typescript/package.json index 2907f5bb59..1e0f39b98e 100644 --- a/examples/react/basic-typescript/package.json +++ b/examples/react/basic-typescript/package.json @@ -9,10 +9,10 @@ "test:types": "tsc" }, "dependencies": { - "@tanstack/query-sync-storage-persister": "^5.22.2", - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", - "@tanstack/react-query-persist-client": "^5.22.2", + "@tanstack/query-sync-storage-persister": "^5.24.1", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", + "@tanstack/react-query-persist-client": "^5.24.1", "axios": "^1.6.7", "react": "^18.2.0", "react-dom": "^18.2.0" diff --git a/examples/react/basic/package.json b/examples/react/basic/package.json index 7c72b4b221..f5887acf74 100644 --- a/examples/react/basic/package.json +++ b/examples/react/basic/package.json @@ -8,8 +8,8 @@ "preview": "vite preview" }, "dependencies": { - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "axios": "^1.6.7", "react": "^18.2.0", "react-dom": "^18.2.0" diff --git a/examples/react/default-query-function/package.json b/examples/react/default-query-function/package.json index 6dd1765bfd..405ba743f9 100644 --- a/examples/react/default-query-function/package.json +++ b/examples/react/default-query-function/package.json @@ -8,8 +8,8 @@ "preview": "vite preview" }, "dependencies": { - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "axios": "^1.6.7", "react": "^18.2.0", "react-dom": "^18.2.0" diff --git a/examples/react/infinite-query-with-max-pages/package.json b/examples/react/infinite-query-with-max-pages/package.json index 6946841240..9d4f0bef1a 100644 --- a/examples/react/infinite-query-with-max-pages/package.json +++ b/examples/react/infinite-query-with-max-pages/package.json @@ -7,8 +7,8 @@ "start": "next start" }, "dependencies": { - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "axios": "^1.6.7", "isomorphic-unfetch": "4.0.2", "next": "^14.0.0", diff --git a/examples/react/load-more-infinite-scroll/package.json b/examples/react/load-more-infinite-scroll/package.json index 31eaa3b780..d5de40889b 100644 --- a/examples/react/load-more-infinite-scroll/package.json +++ b/examples/react/load-more-infinite-scroll/package.json @@ -7,8 +7,8 @@ "start": "next start" }, "dependencies": { - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "axios": "^1.6.7", "isomorphic-unfetch": "4.0.2", "next": "^14.0.0", diff --git a/examples/react/nextjs-suspense-streaming/package.json b/examples/react/nextjs-suspense-streaming/package.json index 55f02e843f..87ea3a3e4e 100644 --- a/examples/react/nextjs-suspense-streaming/package.json +++ b/examples/react/nextjs-suspense-streaming/package.json @@ -8,9 +8,9 @@ "test:types": "tsc" }, "dependencies": { - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", - "@tanstack/react-query-next-experimental": "^5.22.2", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", + "@tanstack/react-query-next-experimental": "^5.24.1", "next": "^14.0.0", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/examples/react/nextjs/package.json b/examples/react/nextjs/package.json index 5ed0490287..95e770f0a0 100644 --- a/examples/react/nextjs/package.json +++ b/examples/react/nextjs/package.json @@ -7,8 +7,8 @@ "start": "next start" }, "dependencies": { - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "ky": "^1.2.0", "next": "^14.0.0", "react": "^18.2.0", diff --git a/examples/react/offline/package.json b/examples/react/offline/package.json index 20fe3e39da..9aa9dff2b8 100644 --- a/examples/react/offline/package.json +++ b/examples/react/offline/package.json @@ -8,11 +8,11 @@ "preview": "vite preview" }, "dependencies": { - "@tanstack/query-sync-storage-persister": "^5.22.2", + "@tanstack/query-sync-storage-persister": "^5.24.1", "@tanstack/react-location": "^3.7.4", - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", - "@tanstack/react-query-persist-client": "^5.22.2", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", + "@tanstack/react-query-persist-client": "^5.24.1", "ky": "^1.2.0", "msw": "^2.1.7", "react": "^18.2.0", diff --git a/examples/react/optimistic-updates-cache/package.json b/examples/react/optimistic-updates-cache/package.json index ef81dfd9d3..2f560e3ec2 100755 --- a/examples/react/optimistic-updates-cache/package.json +++ b/examples/react/optimistic-updates-cache/package.json @@ -8,8 +8,8 @@ "test:types": "tsc" }, "dependencies": { - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "axios": "^1.6.7", "isomorphic-unfetch": "4.0.2", "next": "^14.0.0", diff --git a/examples/react/optimistic-updates-ui/package.json b/examples/react/optimistic-updates-ui/package.json index c4effce6a5..23840c1c04 100755 --- a/examples/react/optimistic-updates-ui/package.json +++ b/examples/react/optimistic-updates-ui/package.json @@ -7,8 +7,8 @@ "start": "next start" }, "dependencies": { - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "axios": "^1.6.7", "isomorphic-unfetch": "4.0.2", "next": "^14.0.0", diff --git a/examples/react/pagination/package.json b/examples/react/pagination/package.json index c820148b4a..2e58172596 100644 --- a/examples/react/pagination/package.json +++ b/examples/react/pagination/package.json @@ -7,8 +7,8 @@ "start": "next start" }, "dependencies": { - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "axios": "^1.6.7", "isomorphic-unfetch": "4.0.2", "next": "^14.0.0", diff --git a/examples/react/playground/package.json b/examples/react/playground/package.json index 6256e4c0ac..982f5b1e4c 100644 --- a/examples/react/playground/package.json +++ b/examples/react/playground/package.json @@ -8,8 +8,8 @@ "preview": "vite preview" }, "dependencies": { - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "react": "^18.2.0", "react-dom": "^18.2.0" }, diff --git a/examples/react/prefetching/package.json b/examples/react/prefetching/package.json index 0dae5b985f..ccc0c4970f 100644 --- a/examples/react/prefetching/package.json +++ b/examples/react/prefetching/package.json @@ -7,8 +7,8 @@ "start": "next start" }, "dependencies": { - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "axios": "^1.6.7", "isomorphic-unfetch": "4.0.2", "next": "^14.0.0", diff --git a/examples/react/react-native/package.json b/examples/react/react-native/package.json index 0567238de7..9b5d076c71 100644 --- a/examples/react/react-native/package.json +++ b/examples/react/react-native/package.json @@ -14,8 +14,8 @@ "@react-native-community/netinfo": "^11.1.0", "@react-navigation/native": "^6.1.6", "@react-navigation/stack": "^6.3.16", - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "expo": "^50.0.6", "expo-constants": "^15.4.5", "expo-status-bar": "^1.11.1", diff --git a/examples/react/react-router/package.json b/examples/react/react-router/package.json index 0705b0d9ec..6051a60bd6 100644 --- a/examples/react/react-router/package.json +++ b/examples/react/react-router/package.json @@ -9,8 +9,8 @@ "test:types": "tsc" }, "dependencies": { - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "localforage": "^1.10.0", "match-sorter": "^6.3.4", "react": "^18.2.0", diff --git a/examples/react/rick-morty/package.json b/examples/react/rick-morty/package.json index 1869578501..1d124bd954 100644 --- a/examples/react/rick-morty/package.json +++ b/examples/react/rick-morty/package.json @@ -12,8 +12,8 @@ "@emotion/styled": "^11.11.0", "@mui/material": "^5.15.2", "@mui/styles": "^5.15.2", - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router": "^6.22.0", diff --git a/examples/react/simple/package.json b/examples/react/simple/package.json index 987956e6d1..8d1f5b7f22 100644 --- a/examples/react/simple/package.json +++ b/examples/react/simple/package.json @@ -8,8 +8,8 @@ "preview": "vite preview" }, "dependencies": { - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "axios": "^1.6.7", "react": "^18.2.0", "react-dom": "^18.2.0" diff --git a/examples/react/star-wars/package.json b/examples/react/star-wars/package.json index d77bedf8dd..c765e15199 100644 --- a/examples/react/star-wars/package.json +++ b/examples/react/star-wars/package.json @@ -12,8 +12,8 @@ "@emotion/styled": "^11.11.0", "@mui/material": "^5.15.2", "@mui/styles": "^5.15.2", - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router": "^6.22.0", diff --git a/examples/react/suspense/package.json b/examples/react/suspense/package.json index 81f200497e..938fcfb1a4 100644 --- a/examples/react/suspense/package.json +++ b/examples/react/suspense/package.json @@ -3,8 +3,8 @@ "private": true, "type": "module", "dependencies": { - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-query-devtools": "^5.24.0", + "@tanstack/react-query": "^5.24.1", + "@tanstack/react-query-devtools": "^5.24.1", "axios": "^1.6.7", "font-awesome": "^4.7.0", "react": "^18.2.0", diff --git a/examples/solid/basic-graphql-request/package.json b/examples/solid/basic-graphql-request/package.json index 97f40730a4..93fd007b79 100644 --- a/examples/solid/basic-graphql-request/package.json +++ b/examples/solid/basic-graphql-request/package.json @@ -9,8 +9,8 @@ "test:types": "tsc" }, "dependencies": { - "@tanstack/solid-query": "^5.22.2", - "@tanstack/solid-query-devtools": "^5.24.0", + "@tanstack/solid-query": "^5.24.1", + "@tanstack/solid-query-devtools": "^5.24.1", "graphql": "^16.8.1", "graphql-request": "^6.1.0", "solid-js": "^1.8.14" diff --git a/examples/solid/basic-typescript/package.json b/examples/solid/basic-typescript/package.json index 561d46d12b..f0d299ee24 100644 --- a/examples/solid/basic-typescript/package.json +++ b/examples/solid/basic-typescript/package.json @@ -9,8 +9,8 @@ "test:types": "tsc" }, "dependencies": { - "@tanstack/solid-query": "^5.22.2", - "@tanstack/solid-query-devtools": "^5.24.0", + "@tanstack/solid-query": "^5.24.1", + "@tanstack/solid-query-devtools": "^5.24.1", "solid-js": "^1.8.14" }, "devDependencies": { diff --git a/examples/solid/default-query-function/package.json b/examples/solid/default-query-function/package.json index f775b5ee56..c74d4fb617 100644 --- a/examples/solid/default-query-function/package.json +++ b/examples/solid/default-query-function/package.json @@ -9,8 +9,8 @@ "test:types": "tsc" }, "dependencies": { - "@tanstack/solid-query": "^5.22.2", - "@tanstack/solid-query-devtools": "^5.24.0", + "@tanstack/solid-query": "^5.24.1", + "@tanstack/solid-query-devtools": "^5.24.1", "solid-js": "^1.8.14" }, "devDependencies": { diff --git a/examples/solid/simple/package.json b/examples/solid/simple/package.json index aab9737872..2bdc3a8652 100644 --- a/examples/solid/simple/package.json +++ b/examples/solid/simple/package.json @@ -9,8 +9,8 @@ "test:types": "tsc" }, "dependencies": { - "@tanstack/solid-query": "^5.22.2", - "@tanstack/solid-query-devtools": "^5.24.0", + "@tanstack/solid-query": "^5.24.1", + "@tanstack/solid-query-devtools": "^5.24.1", "solid-js": "^1.8.14" }, "devDependencies": { diff --git a/examples/solid/solid-start-streaming/package.json b/examples/solid/solid-start-streaming/package.json index 118af55d0e..7ccb1d0342 100644 --- a/examples/solid/solid-start-streaming/package.json +++ b/examples/solid/solid-start-streaming/package.json @@ -11,8 +11,8 @@ "@solidjs/meta": "^0.29.3", "@solidjs/router": "^0.12.0", "@solidjs/start": "^0.5.4", - "@tanstack/solid-query": "^5.22.2", - "@tanstack/solid-query-devtools": "^5.24.0", + "@tanstack/solid-query": "^5.24.1", + "@tanstack/solid-query-devtools": "^5.24.1", "solid-js": "^1.8.14", "vinxi": "^0.3.3" }, diff --git a/examples/svelte/auto-refetching/package.json b/examples/svelte/auto-refetching/package.json index 450f1a8650..6986d7d7be 100644 --- a/examples/svelte/auto-refetching/package.json +++ b/examples/svelte/auto-refetching/package.json @@ -9,8 +9,8 @@ "test:types": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json" }, "dependencies": { - "@tanstack/svelte-query": "^5.22.2", - "@tanstack/svelte-query-devtools": "^5.24.0" + "@tanstack/svelte-query": "^5.24.1", + "@tanstack/svelte-query-devtools": "^5.24.1" }, "devDependencies": { "@sveltejs/adapter-auto": "^3.1.1", diff --git a/examples/svelte/basic/package.json b/examples/svelte/basic/package.json index 740648b270..2954b8a4d9 100644 --- a/examples/svelte/basic/package.json +++ b/examples/svelte/basic/package.json @@ -9,8 +9,8 @@ "test:types": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json" }, "dependencies": { - "@tanstack/svelte-query": "^5.22.2", - "@tanstack/svelte-query-devtools": "^5.24.0" + "@tanstack/svelte-query": "^5.24.1", + "@tanstack/svelte-query-devtools": "^5.24.1" }, "devDependencies": { "@sveltejs/adapter-auto": "^3.1.1", diff --git a/examples/svelte/load-more-infinite-scroll/package.json b/examples/svelte/load-more-infinite-scroll/package.json index 63e30d65d1..76b68f1579 100644 --- a/examples/svelte/load-more-infinite-scroll/package.json +++ b/examples/svelte/load-more-infinite-scroll/package.json @@ -9,8 +9,8 @@ "test:types": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json" }, "dependencies": { - "@tanstack/svelte-query": "^5.22.2", - "@tanstack/svelte-query-devtools": "^5.24.0" + "@tanstack/svelte-query": "^5.24.1", + "@tanstack/svelte-query-devtools": "^5.24.1" }, "devDependencies": { "@sveltejs/adapter-auto": "^3.1.1", diff --git a/examples/svelte/optimistic-updates-typescript/package.json b/examples/svelte/optimistic-updates-typescript/package.json index fce01fb159..dd0d001c94 100644 --- a/examples/svelte/optimistic-updates-typescript/package.json +++ b/examples/svelte/optimistic-updates-typescript/package.json @@ -9,8 +9,8 @@ "test:types": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json" }, "dependencies": { - "@tanstack/svelte-query": "^5.22.2", - "@tanstack/svelte-query-devtools": "^5.24.0" + "@tanstack/svelte-query": "^5.24.1", + "@tanstack/svelte-query-devtools": "^5.24.1" }, "devDependencies": { "@sveltejs/adapter-auto": "^3.1.1", diff --git a/examples/svelte/playground/package.json b/examples/svelte/playground/package.json index 826db1b06b..167dba6466 100644 --- a/examples/svelte/playground/package.json +++ b/examples/svelte/playground/package.json @@ -9,8 +9,8 @@ "test:types": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json" }, "dependencies": { - "@tanstack/svelte-query": "^5.22.2", - "@tanstack/svelte-query-devtools": "^5.24.0" + "@tanstack/svelte-query": "^5.24.1", + "@tanstack/svelte-query-devtools": "^5.24.1" }, "devDependencies": { "@sveltejs/adapter-auto": "^3.1.1", diff --git a/examples/svelte/simple/package.json b/examples/svelte/simple/package.json index 4d6a2ba781..4f4804816a 100644 --- a/examples/svelte/simple/package.json +++ b/examples/svelte/simple/package.json @@ -9,8 +9,8 @@ "test:types": "svelte-check --tsconfig ./tsconfig.json" }, "dependencies": { - "@tanstack/svelte-query": "^5.22.2", - "@tanstack/svelte-query-devtools": "^5.24.0" + "@tanstack/svelte-query": "^5.24.1", + "@tanstack/svelte-query-devtools": "^5.24.1" }, "devDependencies": { "@sveltejs/vite-plugin-svelte": "^3.0.2", diff --git a/examples/svelte/ssr/package.json b/examples/svelte/ssr/package.json index f0d38149e5..004c1ad927 100644 --- a/examples/svelte/ssr/package.json +++ b/examples/svelte/ssr/package.json @@ -9,8 +9,8 @@ "test:types": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json" }, "dependencies": { - "@tanstack/svelte-query": "^5.22.2", - "@tanstack/svelte-query-devtools": "^5.24.0" + "@tanstack/svelte-query": "^5.24.1", + "@tanstack/svelte-query-devtools": "^5.24.1" }, "devDependencies": { "@sveltejs/adapter-auto": "^3.1.1", diff --git a/examples/svelte/star-wars/package.json b/examples/svelte/star-wars/package.json index 5df6fb099c..cc51fdb6ca 100644 --- a/examples/svelte/star-wars/package.json +++ b/examples/svelte/star-wars/package.json @@ -9,8 +9,8 @@ "test:types": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json" }, "dependencies": { - "@tanstack/svelte-query": "^5.22.2", - "@tanstack/svelte-query-devtools": "^5.24.0" + "@tanstack/svelte-query": "^5.24.1", + "@tanstack/svelte-query-devtools": "^5.24.1" }, "devDependencies": { "@sveltejs/adapter-auto": "^3.1.1", diff --git a/examples/vue/2.6-basic/package.json b/examples/vue/2.6-basic/package.json index 90ed11d904..7579d2702b 100644 --- a/examples/vue/2.6-basic/package.json +++ b/examples/vue/2.6-basic/package.json @@ -8,7 +8,7 @@ "preview": "vite preview" }, "dependencies": { - "@tanstack/vue-query": "^5.22.2", + "@tanstack/vue-query": "^5.24.1", "@vue/composition-api": "1.7.2", "vue": "2.6.14", "vue-template-compiler": "2.6.14" diff --git a/examples/vue/basic/package.json b/examples/vue/basic/package.json index e7e8dfc82e..9accf892d7 100644 --- a/examples/vue/basic/package.json +++ b/examples/vue/basic/package.json @@ -8,8 +8,8 @@ "preview": "vite preview" }, "dependencies": { - "@tanstack/vue-query": "^5.22.2", - "@tanstack/vue-query-devtools": "^5.24.0", + "@tanstack/vue-query": "^5.24.1", + "@tanstack/vue-query-devtools": "^5.24.1", "vue": "^3.3.0" }, "devDependencies": { diff --git a/examples/vue/dependent-queries/package.json b/examples/vue/dependent-queries/package.json index 73fd38ed36..ad6afb5cb1 100644 --- a/examples/vue/dependent-queries/package.json +++ b/examples/vue/dependent-queries/package.json @@ -8,7 +8,7 @@ "preview": "vite preview" }, "dependencies": { - "@tanstack/vue-query": "^5.22.2", + "@tanstack/vue-query": "^5.24.1", "vue": "^3.3.0" }, "devDependencies": { diff --git a/examples/vue/nuxt3/package.json b/examples/vue/nuxt3/package.json index d9da240191..4103bce760 100644 --- a/examples/vue/nuxt3/package.json +++ b/examples/vue/nuxt3/package.json @@ -7,7 +7,7 @@ "start": "node .output/server/index.mjs" }, "dependencies": { - "@tanstack/vue-query": "^5.22.2" + "@tanstack/vue-query": "^5.24.1" }, "devDependencies": { "nuxt": "^3.5.2" diff --git a/examples/vue/persister/package.json b/examples/vue/persister/package.json index 31f07a11df..6d3a3e533b 100644 --- a/examples/vue/persister/package.json +++ b/examples/vue/persister/package.json @@ -8,10 +8,10 @@ "preview": "vite preview" }, "dependencies": { - "@tanstack/query-core": "^5.22.2", - "@tanstack/query-persist-client-core": "^5.22.2", - "@tanstack/query-sync-storage-persister": "^5.22.2", - "@tanstack/vue-query": "^5.22.2", + "@tanstack/query-core": "^5.24.1", + "@tanstack/query-persist-client-core": "^5.24.1", + "@tanstack/query-sync-storage-persister": "^5.24.1", + "@tanstack/vue-query": "^5.24.1", "idb-keyval": "^6.2.1", "vue": "^3.3.0" }, diff --git a/examples/vue/simple/package.json b/examples/vue/simple/package.json index d94a45ace1..83c8389dea 100644 --- a/examples/vue/simple/package.json +++ b/examples/vue/simple/package.json @@ -8,8 +8,8 @@ "preview": "vite preview" }, "dependencies": { - "@tanstack/vue-query": "^5.22.2", - "@tanstack/vue-query-devtools": "^5.24.0", + "@tanstack/vue-query": "^5.24.1", + "@tanstack/vue-query-devtools": "^5.24.1", "vue": "^3.3.0" }, "devDependencies": { diff --git a/packages/angular-query-devtools-experimental/package.json b/packages/angular-query-devtools-experimental/package.json index d3681840aa..dcd79760a9 100644 --- a/packages/angular-query-devtools-experimental/package.json +++ b/packages/angular-query-devtools-experimental/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/angular-query-devtools-experimental", - "version": "5.24.0", + "version": "5.24.1", "description": "Developer tools to interact with and visualize the TanStack/angular-query cache", "author": "Arnoud de Vries", "license": "MIT", diff --git a/packages/angular-query-experimental/package.json b/packages/angular-query-experimental/package.json index dc81b77623..cd50d75c44 100644 --- a/packages/angular-query-experimental/package.json +++ b/packages/angular-query-experimental/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/angular-query-experimental", - "version": "5.22.2", + "version": "5.24.1", "description": "Signals for managing, caching and syncing asynchronous and remote data in Angular", "author": "Arnoud de Vries", "license": "MIT", diff --git a/packages/query-async-storage-persister/package.json b/packages/query-async-storage-persister/package.json index 2b831837ee..6d365fba0a 100644 --- a/packages/query-async-storage-persister/package.json +++ b/packages/query-async-storage-persister/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/query-async-storage-persister", - "version": "5.22.2", + "version": "5.24.1", "description": "A persister for asynchronous storages, to be used with TanStack/Query", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/query-broadcast-client-experimental/package.json b/packages/query-broadcast-client-experimental/package.json index 0daa0c1cf4..d44cf08749 100644 --- a/packages/query-broadcast-client-experimental/package.json +++ b/packages/query-broadcast-client-experimental/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/query-broadcast-client-experimental", - "version": "5.22.2", + "version": "5.24.1", "description": "An experimental plugin to for broadcasting the state of your queryClient between browser tabs/windows", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/query-core/package.json b/packages/query-core/package.json index 0409909c9d..c904e810dd 100644 --- a/packages/query-core/package.json +++ b/packages/query-core/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/query-core", - "version": "5.22.2", + "version": "5.24.1", "description": "The framework agnostic core that powers TanStack Query", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/query-persist-client-core/package.json b/packages/query-persist-client-core/package.json index 9deb424c8f..0d12970863 100644 --- a/packages/query-persist-client-core/package.json +++ b/packages/query-persist-client-core/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/query-persist-client-core", - "version": "5.22.2", + "version": "5.24.1", "description": "Set of utilities for interacting with persisters, which can save your queryClient for later use", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/query-sync-storage-persister/package.json b/packages/query-sync-storage-persister/package.json index c7fc187348..5f71e82c53 100644 --- a/packages/query-sync-storage-persister/package.json +++ b/packages/query-sync-storage-persister/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/query-sync-storage-persister", - "version": "5.22.2", + "version": "5.24.1", "description": "A persister for synchronous storages, to be used with TanStack/Query", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/react-query-devtools/package.json b/packages/react-query-devtools/package.json index d928fce701..13e966bc2c 100644 --- a/packages/react-query-devtools/package.json +++ b/packages/react-query-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/react-query-devtools", - "version": "5.24.0", + "version": "5.24.1", "description": "Developer tools to interact with and visualize the TanStack/react-query cache", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/react-query-next-experimental/package.json b/packages/react-query-next-experimental/package.json index 213389bb94..07f7a98693 100644 --- a/packages/react-query-next-experimental/package.json +++ b/packages/react-query-next-experimental/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/react-query-next-experimental", - "version": "5.22.2", + "version": "5.24.1", "description": "Hydration utils for React Query in the NextJs app directory", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/react-query-persist-client/package.json b/packages/react-query-persist-client/package.json index bc8b5bc9d4..fce4dd0de6 100644 --- a/packages/react-query-persist-client/package.json +++ b/packages/react-query-persist-client/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/react-query-persist-client", - "version": "5.22.2", + "version": "5.24.1", "description": "React bindings to work with persisters in TanStack/react-query", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/react-query/package.json b/packages/react-query/package.json index 37caef93bd..4467265d72 100644 --- a/packages/react-query/package.json +++ b/packages/react-query/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/react-query", - "version": "5.22.2", + "version": "5.24.1", "description": "Hooks for managing, caching and syncing asynchronous and remote data in React", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/solid-query-devtools/package.json b/packages/solid-query-devtools/package.json index 16535a8ae0..7bd62f5bee 100644 --- a/packages/solid-query-devtools/package.json +++ b/packages/solid-query-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/solid-query-devtools", - "version": "5.24.0", + "version": "5.24.1", "description": "Developer tools to interact with and visualize the TanStack/solid-query Query cache", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/solid-query-persist-client/package.json b/packages/solid-query-persist-client/package.json index 4a765baa42..7df89e63d6 100644 --- a/packages/solid-query-persist-client/package.json +++ b/packages/solid-query-persist-client/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/solid-query-persist-client", - "version": "5.22.2", + "version": "5.24.1", "description": "Solid.js bindings to work with persisters in TanStack/solid-query", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/solid-query/package.json b/packages/solid-query/package.json index 2a953aeded..162eb85fd9 100644 --- a/packages/solid-query/package.json +++ b/packages/solid-query/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/solid-query", - "version": "5.22.2", + "version": "5.24.1", "description": "Primitives for managing, caching and syncing asynchronous and remote data in Solid", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/svelte-query-devtools/package.json b/packages/svelte-query-devtools/package.json index ea6f3bc309..363826688e 100644 --- a/packages/svelte-query-devtools/package.json +++ b/packages/svelte-query-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/svelte-query-devtools", - "version": "5.24.0", + "version": "5.24.1", "description": "Developer tools to interact with and visualize the TanStack/svelte-query cache", "author": "Lachlan Collins", "license": "MIT", diff --git a/packages/svelte-query-persist-client/package.json b/packages/svelte-query-persist-client/package.json index a9fabdde2a..0f06c17681 100644 --- a/packages/svelte-query-persist-client/package.json +++ b/packages/svelte-query-persist-client/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/svelte-query-persist-client", - "version": "5.22.2", + "version": "5.24.1", "description": "Svelte bindings to work with persisters in TanStack/svelte-query", "author": "Lachlan Collins", "license": "MIT", diff --git a/packages/svelte-query/package.json b/packages/svelte-query/package.json index 59598ba365..ca9960b513 100644 --- a/packages/svelte-query/package.json +++ b/packages/svelte-query/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/svelte-query", - "version": "5.22.2", + "version": "5.24.1", "description": "Primitives for managing, caching and syncing asynchronous and remote data in Svelte", "author": "Lachlan Collins", "license": "MIT", diff --git a/packages/vue-query-devtools/package.json b/packages/vue-query-devtools/package.json index e25e159551..9f093f9440 100644 --- a/packages/vue-query-devtools/package.json +++ b/packages/vue-query-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/vue-query-devtools", - "version": "5.24.0", + "version": "5.24.1", "description": "Developer tools to interact with and visualize the TanStack/vue-query cache", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/vue-query/package.json b/packages/vue-query/package.json index c8610885ea..a602b10e81 100644 --- a/packages/vue-query/package.json +++ b/packages/vue-query/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/vue-query", - "version": "5.22.2", + "version": "5.24.1", "description": "Hooks for managing, caching and syncing asynchronous and remote data in Vue", "author": "Damian Osipiuk", "license": "MIT", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ed069b0fb0..e79a5f6730 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -146,7 +146,7 @@ importers: specifier: ^17.1.3 version: 17.1.3(@angular/common@17.1.3)(@angular/core@17.1.3)(@angular/platform-browser@17.1.3)(rxjs@7.8.1) '@tanstack/angular-query-experimental': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/angular-query-experimental rxjs: specifier: ^7.8.1 @@ -168,7 +168,7 @@ importers: specifier: ^17.1.3 version: 17.1.3(@angular/compiler@17.1.3)(typescript@5.2.2) '@tanstack/angular-query-devtools-experimental': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/angular-query-devtools-experimental typescript: specifier: 5.2.2 @@ -201,7 +201,7 @@ importers: specifier: ^17.1.3 version: 17.1.3(@angular/common@17.1.3)(@angular/core@17.1.3)(@angular/platform-browser@17.1.3)(rxjs@7.8.1) '@tanstack/angular-query-experimental': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/angular-query-experimental rxjs: specifier: ^7.8.1 @@ -223,7 +223,7 @@ importers: specifier: ^17.1.3 version: 17.1.3(@angular/compiler@17.1.3)(typescript@5.2.2) '@tanstack/angular-query-devtools-experimental': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/angular-query-devtools-experimental typescript: specifier: 5.2.2 @@ -256,7 +256,7 @@ importers: specifier: ^17.1.3 version: 17.1.3(@angular/common@17.1.3)(@angular/core@17.1.3)(@angular/platform-browser@17.1.3)(rxjs@7.8.1) '@tanstack/angular-query-experimental': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/angular-query-experimental rxjs: specifier: ^7.8.1 @@ -278,7 +278,7 @@ importers: specifier: ^17.1.3 version: 17.1.3(@angular/compiler@17.1.3)(typescript@5.2.2) '@tanstack/angular-query-devtools-experimental': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/angular-query-devtools-experimental typescript: specifier: 5.2.2 @@ -311,7 +311,7 @@ importers: specifier: ^17.1.3 version: 17.1.3(@angular/common@17.1.3)(@angular/core@17.1.3)(@angular/platform-browser@17.1.3)(rxjs@7.8.1) '@tanstack/angular-query-experimental': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/angular-query-experimental rxjs: specifier: ^7.8.1 @@ -333,7 +333,7 @@ importers: specifier: ^17.1.3 version: 17.1.3(@angular/compiler@17.1.3)(typescript@5.2.2) '@tanstack/angular-query-devtools-experimental': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/angular-query-devtools-experimental typescript: specifier: 5.2.2 @@ -348,10 +348,10 @@ importers: specifier: 4.22.1 version: 4.22.1 '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools algoliasearch: specifier: 4.22.1 @@ -385,10 +385,10 @@ importers: examples/react/auto-refetching: dependencies: '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools axios: specifier: ^1.6.7 @@ -409,10 +409,10 @@ importers: examples/react/basic: dependencies: '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools axios: specifier: ^1.6.7 @@ -437,10 +437,10 @@ importers: examples/react/basic-graphql-request: dependencies: '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools graphql: specifier: ^16.8.1 @@ -465,16 +465,16 @@ importers: examples/react/basic-typescript: dependencies: '@tanstack/query-sync-storage-persister': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/query-sync-storage-persister '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools '@tanstack/react-query-persist-client': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query-persist-client axios: specifier: ^1.6.7 @@ -514,10 +514,10 @@ importers: examples/react/default-query-function: dependencies: '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools axios: specifier: ^1.6.7 @@ -539,10 +539,10 @@ importers: examples/react/infinite-query-with-max-pages: dependencies: '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools axios: specifier: ^1.6.7 @@ -566,10 +566,10 @@ importers: examples/react/load-more-infinite-scroll: dependencies: '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools axios: specifier: ^1.6.7 @@ -593,10 +593,10 @@ importers: examples/react/nextjs: dependencies: '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools ky: specifier: ^1.2.0 @@ -620,13 +620,13 @@ importers: examples/react/nextjs-suspense-streaming: dependencies: '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools '@tanstack/react-query-next-experimental': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query-next-experimental next: specifier: ^14.0.0 @@ -654,19 +654,19 @@ importers: examples/react/offline: dependencies: '@tanstack/query-sync-storage-persister': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/query-sync-storage-persister '@tanstack/react-location': specifier: ^3.7.4 version: 3.7.4(react-dom@18.2.0)(react@18.2.0) '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools '@tanstack/react-query-persist-client': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query-persist-client ky: specifier: ^1.2.0 @@ -694,10 +694,10 @@ importers: examples/react/optimistic-updates-cache: dependencies: '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools axios: specifier: ^1.6.7 @@ -731,10 +731,10 @@ importers: examples/react/optimistic-updates-ui: dependencies: '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools axios: specifier: ^1.6.7 @@ -768,10 +768,10 @@ importers: examples/react/pagination: dependencies: '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools axios: specifier: ^1.6.7 @@ -792,10 +792,10 @@ importers: examples/react/playground: dependencies: '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools react: specifier: ^18.2.0 @@ -814,10 +814,10 @@ importers: examples/react/prefetching: dependencies: '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools axios: specifier: ^1.6.7 @@ -847,10 +847,10 @@ importers: specifier: ^6.3.16 version: 6.3.16(@react-navigation/native@6.1.6)(react-native-gesture-handler@2.15.0)(react-native-safe-area-context@4.9.0)(react-native-screens@3.29.0)(react-native@0.73.4)(react@18.2.0) '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools expo: specifier: ^50.0.6 @@ -899,10 +899,10 @@ importers: examples/react/react-router: dependencies: '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools localforage: specifier: ^1.10.0 @@ -963,10 +963,10 @@ importers: specifier: ^5.15.2 version: 5.15.2(@types/react@18.2.55)(react@18.2.0) '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools react: specifier: ^18.2.0 @@ -991,10 +991,10 @@ importers: examples/react/simple: dependencies: '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools axios: specifier: ^1.6.7 @@ -1028,10 +1028,10 @@ importers: specifier: ^5.15.2 version: 5.15.2(@types/react@18.2.55)(react@18.2.0) '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools react: specifier: ^18.2.0 @@ -1056,10 +1056,10 @@ importers: examples/react/suspense: dependencies: '@tanstack/react-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/react-query '@tanstack/react-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/react-query-devtools axios: specifier: ^1.6.7 @@ -1087,10 +1087,10 @@ importers: examples/solid/basic-graphql-request: dependencies: '@tanstack/solid-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/solid-query '@tanstack/solid-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/solid-query-devtools graphql: specifier: ^16.8.1 @@ -1115,10 +1115,10 @@ importers: examples/solid/basic-typescript: dependencies: '@tanstack/solid-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/solid-query '@tanstack/solid-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/solid-query-devtools solid-js: specifier: ^1.8.14 @@ -1137,10 +1137,10 @@ importers: examples/solid/default-query-function: dependencies: '@tanstack/solid-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/solid-query '@tanstack/solid-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/solid-query-devtools solid-js: specifier: ^1.8.14 @@ -1159,10 +1159,10 @@ importers: examples/solid/simple: dependencies: '@tanstack/solid-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/solid-query '@tanstack/solid-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/solid-query-devtools solid-js: specifier: ^1.8.14 @@ -1193,10 +1193,10 @@ importers: specifier: ^0.5.4 version: 0.5.4(@testing-library/jest-dom@6.4.2)(rollup@4.6.0)(solid-js@1.8.14)(vinxi@0.3.3)(vite@4.5.1) '@tanstack/solid-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/solid-query '@tanstack/solid-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/solid-query-devtools solid-js: specifier: ^1.8.14 @@ -1208,10 +1208,10 @@ importers: examples/svelte/auto-refetching: dependencies: '@tanstack/svelte-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/svelte-query '@tanstack/svelte-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/svelte-query-devtools devDependencies: '@sveltejs/adapter-auto': @@ -1239,10 +1239,10 @@ importers: examples/svelte/basic: dependencies: '@tanstack/svelte-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/svelte-query '@tanstack/svelte-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/svelte-query-devtools devDependencies: '@sveltejs/adapter-auto': @@ -1270,10 +1270,10 @@ importers: examples/svelte/load-more-infinite-scroll: dependencies: '@tanstack/svelte-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/svelte-query '@tanstack/svelte-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/svelte-query-devtools devDependencies: '@sveltejs/adapter-auto': @@ -1301,10 +1301,10 @@ importers: examples/svelte/optimistic-updates-typescript: dependencies: '@tanstack/svelte-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/svelte-query '@tanstack/svelte-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/svelte-query-devtools devDependencies: '@sveltejs/adapter-auto': @@ -1332,10 +1332,10 @@ importers: examples/svelte/playground: dependencies: '@tanstack/svelte-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/svelte-query '@tanstack/svelte-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/svelte-query-devtools devDependencies: '@sveltejs/adapter-auto': @@ -1363,10 +1363,10 @@ importers: examples/svelte/simple: dependencies: '@tanstack/svelte-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/svelte-query '@tanstack/svelte-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/svelte-query-devtools devDependencies: '@sveltejs/vite-plugin-svelte': @@ -1391,10 +1391,10 @@ importers: examples/svelte/ssr: dependencies: '@tanstack/svelte-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/svelte-query '@tanstack/svelte-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/svelte-query-devtools devDependencies: '@sveltejs/adapter-auto': @@ -1422,10 +1422,10 @@ importers: examples/svelte/star-wars: dependencies: '@tanstack/svelte-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/svelte-query '@tanstack/svelte-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/svelte-query-devtools devDependencies: '@sveltejs/adapter-auto': @@ -1462,10 +1462,10 @@ importers: examples/vue/basic: dependencies: '@tanstack/vue-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/vue-query '@tanstack/vue-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/vue-query-devtools vue: specifier: ^3.3.0 @@ -1484,7 +1484,7 @@ importers: examples/vue/dependent-queries: dependencies: '@tanstack/vue-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/vue-query vue: specifier: ^3.3.0 @@ -1503,16 +1503,16 @@ importers: examples/vue/persister: dependencies: '@tanstack/query-core': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/query-core '@tanstack/query-persist-client-core': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/query-persist-client-core '@tanstack/query-sync-storage-persister': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/query-sync-storage-persister '@tanstack/vue-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/vue-query idb-keyval: specifier: ^6.2.1 @@ -1534,10 +1534,10 @@ importers: examples/vue/simple: dependencies: '@tanstack/vue-query': - specifier: ^5.22.2 + specifier: ^5.24.1 version: link:../../../packages/vue-query '@tanstack/vue-query-devtools': - specifier: ^5.24.0 + specifier: ^5.24.1 version: link:../../../packages/vue-query-devtools vue: specifier: ^3.3.0 From ef3a0df0b1c055b37ec05e66fd4cd85a3dfa677b Mon Sep 17 00:00:00 2001 From: Arnoud <6420061+arnoud-dv@users.noreply.github.com> Date: Sun, 25 Feb 2024 02:34:43 +0100 Subject: [PATCH 04/10] chore(angular-query): disable cache in Angular examples (#6970) --- examples/angular/basic/angular.json | 5 ++++- examples/angular/infinite-query-with-max-pages/angular.json | 5 ++++- examples/angular/router/angular.json | 5 ++++- examples/angular/simple/angular.json | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/angular/basic/angular.json b/examples/angular/basic/angular.json index b4feedff8b..1256bd9784 100644 --- a/examples/angular/basic/angular.json +++ b/examples/angular/basic/angular.json @@ -3,7 +3,10 @@ "version": 1, "cli": { "packageManager": "pnpm", - "analytics": false + "analytics": false, + "cache": { + "enabled": false + } }, "newProjectRoot": "projects", "projects": { diff --git a/examples/angular/infinite-query-with-max-pages/angular.json b/examples/angular/infinite-query-with-max-pages/angular.json index cbf54a7a41..c105727c39 100644 --- a/examples/angular/infinite-query-with-max-pages/angular.json +++ b/examples/angular/infinite-query-with-max-pages/angular.json @@ -3,7 +3,10 @@ "version": 1, "cli": { "packageManager": "pnpm", - "analytics": false + "analytics": false, + "cache": { + "enabled": false + } }, "newProjectRoot": "projects", "projects": { diff --git a/examples/angular/router/angular.json b/examples/angular/router/angular.json index 1b5cd74c2c..b85aefa62c 100644 --- a/examples/angular/router/angular.json +++ b/examples/angular/router/angular.json @@ -3,7 +3,10 @@ "version": 1, "cli": { "packageManager": "pnpm", - "analytics": false + "analytics": false, + "cache": { + "enabled": false + } }, "newProjectRoot": "projects", "projects": { diff --git a/examples/angular/simple/angular.json b/examples/angular/simple/angular.json index 8c600c0813..ba287d01db 100644 --- a/examples/angular/simple/angular.json +++ b/examples/angular/simple/angular.json @@ -3,7 +3,10 @@ "version": 1, "cli": { "packageManager": "pnpm", - "analytics": false + "analytics": false, + "cache": { + "enabled": false + } }, "newProjectRoot": "projects", "projects": { From d83aa272fb4da68d95c68c72e83b90b3cf9525e4 Mon Sep 17 00:00:00 2001 From: Ekam Ahuja <82745601+ekamahuja@users.noreply.github.com> Date: Sun, 25 Feb 2024 19:15:32 +1000 Subject: [PATCH 05/10] docs: Updated installation commands with bun package manger (#6971) --- docs/eslint/eslint-plugin-query.md | 2 ++ docs/framework/angular/devtools.md | 2 ++ docs/framework/angular/installation.md | 2 ++ docs/framework/react/devtools.md | 2 ++ docs/framework/react/installation.md | 4 ++++ docs/framework/react/plugins/createAsyncStoragePersister.md | 6 ++++++ docs/framework/react/plugins/createPersister.md | 6 ++++++ docs/framework/react/plugins/createSyncStoragePersister.md | 6 ++++++ docs/framework/solid/devtools.md | 3 +++ docs/framework/svelte/installation.md | 2 ++ docs/framework/vue/devtools.md | 2 ++ docs/framework/vue/installation.md | 2 ++ examples/angular/basic/README.md | 4 ++-- examples/angular/infinite-query-with-max-pages/README.md | 4 ++-- examples/angular/router/README.md | 4 ++-- examples/angular/simple/README.md | 4 ++-- examples/svelte/auto-refetching/README.md | 2 +- examples/svelte/basic/README.md | 2 +- examples/svelte/load-more-infinite-scroll/README.md | 2 +- examples/svelte/optimistic-updates-typescript/README.md | 2 +- examples/svelte/ssr/README.md | 2 +- examples/vue/2.6-basic/README.md | 4 ++-- examples/vue/basic/README.md | 4 ++-- examples/vue/simple/README.md | 4 ++-- packages/angular-query-experimental/README.md | 2 ++ packages/vue-query/README.md | 2 ++ 26 files changed, 62 insertions(+), 19 deletions(-) diff --git a/docs/eslint/eslint-plugin-query.md b/docs/eslint/eslint-plugin-query.md index 397ca7ad15..20e5d8a30d 100644 --- a/docs/eslint/eslint-plugin-query.md +++ b/docs/eslint/eslint-plugin-query.md @@ -15,6 +15,8 @@ $ npm i -D @tanstack/eslint-plugin-query $ pnpm add -D @tanstack/eslint-plugin-query # or $ yarn add -D @tanstack/eslint-plugin-query +# or +$ bun add -D @tanstack/eslint-plugin-query ``` ## Usage diff --git a/docs/framework/angular/devtools.md b/docs/framework/angular/devtools.md index ab1f8ef762..539efab38a 100644 --- a/docs/framework/angular/devtools.md +++ b/docs/framework/angular/devtools.md @@ -13,6 +13,8 @@ $ npm i @tanstack/angular-query-devtools-experimental $ pnpm add @tanstack/angular-query-devtools-experimental # or $ yarn add @tanstack/angular-query-devtools-experimental +# or +$ bun add @tanstack/angular-query-devtools-experimental ``` You can import the devtools like this: diff --git a/docs/framework/angular/installation.md b/docs/framework/angular/installation.md index cdfdc636cc..b5a7cc4d31 100644 --- a/docs/framework/angular/installation.md +++ b/docs/framework/angular/installation.md @@ -15,6 +15,8 @@ $ npm i @tanstack/angular-query-experimental $ pnpm add @tanstack/angular-query-experimental # or $ yarn add @tanstack/angular-query-experimental +# or +$ bun add @tanstack/angular-query-experimental ``` > Wanna give it a spin before you download? Try out the [simple](./examples/simple) or [basic](./examples/basic) examples! diff --git a/docs/framework/react/devtools.md b/docs/framework/react/devtools.md index e2e313d1ef..dd3e7fd31b 100644 --- a/docs/framework/react/devtools.md +++ b/docs/framework/react/devtools.md @@ -23,6 +23,8 @@ $ npm i @tanstack/react-query-devtools $ pnpm add @tanstack/react-query-devtools # or $ yarn add @tanstack/react-query-devtools +# or +$ bun add @tanstack/react-query-devtools ``` For Next 13+ App Dir you must install it as a dev dependency for it to work. diff --git a/docs/framework/react/installation.md b/docs/framework/react/installation.md index 80e1df47ab..c1291756e6 100644 --- a/docs/framework/react/installation.md +++ b/docs/framework/react/installation.md @@ -15,6 +15,8 @@ $ npm i @tanstack/react-query $ pnpm add @tanstack/react-query # or $ yarn add @tanstack/react-query +# or +$ bun add @tanstack/react-query ``` React Query is compatible with React v18+ and works with ReactDOM and React Native. @@ -60,4 +62,6 @@ $ npm i -D @tanstack/eslint-plugin-query $ pnpm add -D @tanstack/eslint-plugin-query # or $ yarn add -D @tanstack/eslint-plugin-query +# or +$ bun add -D @tanstack/eslint-plugin-query ``` diff --git a/docs/framework/react/plugins/createAsyncStoragePersister.md b/docs/framework/react/plugins/createAsyncStoragePersister.md index 28ba7dd098..8e59124e0e 100644 --- a/docs/framework/react/plugins/createAsyncStoragePersister.md +++ b/docs/framework/react/plugins/createAsyncStoragePersister.md @@ -23,6 +23,12 @@ or yarn add @tanstack/query-async-storage-persister @tanstack/react-query-persist-client ``` +or + +```bash +bun add @tanstack/query-async-storage-persister @tanstack/react-query-persist-client +``` + ## Usage - Import the `createAsyncStoragePersister` function diff --git a/docs/framework/react/plugins/createPersister.md b/docs/framework/react/plugins/createPersister.md index ba72da4f54..24206b8bfc 100644 --- a/docs/framework/react/plugins/createPersister.md +++ b/docs/framework/react/plugins/createPersister.md @@ -23,6 +23,12 @@ or yarn add @tanstack/query-persist-client-core ``` +or + +```bash +bun add @tanstack/query-persist-client-core +``` + > Note: This util is also included in the `@tanstack/react-query-persist-client` package, so you do not need to install it separately if you are using that package. ## Usage diff --git a/docs/framework/react/plugins/createSyncStoragePersister.md b/docs/framework/react/plugins/createSyncStoragePersister.md index 4b7ba3b97d..85d66a1f82 100644 --- a/docs/framework/react/plugins/createSyncStoragePersister.md +++ b/docs/framework/react/plugins/createSyncStoragePersister.md @@ -23,6 +23,12 @@ or yarn add @tanstack/query-sync-storage-persister @tanstack/react-query-persist-client ``` +or + +```bash +bun add @tanstack/query-sync-storage-persister @tanstack/react-query-persist-client +``` + ## Usage - Import the `createSyncStoragePersister` function diff --git a/docs/framework/solid/devtools.md b/docs/framework/solid/devtools.md index d19f86e48a..78a46db216 100644 --- a/docs/framework/solid/devtools.md +++ b/docs/framework/solid/devtools.md @@ -19,8 +19,11 @@ $ npm i @tanstack/solid-query-devtools $ pnpm add @tanstack/solid-query-devtools # or $ yarn add @tanstack/solid-query-devtools +# or +$ bun add @tanstack/solid-query-devtools ``` + You can import the devtools like this: ```tsx diff --git a/docs/framework/svelte/installation.md b/docs/framework/svelte/installation.md index 2e4bc94e96..773f5aa413 100644 --- a/docs/framework/svelte/installation.md +++ b/docs/framework/svelte/installation.md @@ -15,6 +15,8 @@ $ npm i @tanstack/svelte-query $ pnpm add @tanstack/svelte-query # or $ yarn add @tanstack/svelte-query +# or +$ bun add @tanstack/svelte-query ``` > Wanna give it a spin before you download? Try out the [basic](./examples/basic) example! diff --git a/docs/framework/vue/devtools.md b/docs/framework/vue/devtools.md index f6718c005f..453a219030 100644 --- a/docs/framework/vue/devtools.md +++ b/docs/framework/vue/devtools.md @@ -25,6 +25,8 @@ $ npm i @tanstack/vue-query-devtools $ pnpm add @tanstack/vue-query-devtools # or $ yarn add @tanstack/vue-query-devtools +# or +$ bun add @tanstack/vue-query-devtools ``` By default, Vue Query Devtools are only included in bundles when `process.env.NODE_ENV === 'development'`, so you don't need to worry about excluding them during a production build. diff --git a/docs/framework/vue/installation.md b/docs/framework/vue/installation.md index fe046c653f..39bd6f4a0f 100644 --- a/docs/framework/vue/installation.md +++ b/docs/framework/vue/installation.md @@ -15,6 +15,8 @@ $ npm i @tanstack/vue-query $ pnpm add @tanstack/vue-query # or $ yarn add @tanstack/vue-query +# or +$ bun add @tanstack/vue-query ``` > Wanna give it a spin before you download? Try out the [basic](./examples/basic) example! diff --git a/examples/angular/basic/README.md b/examples/angular/basic/README.md index fa82938f2b..091e861860 100644 --- a/examples/angular/basic/README.md +++ b/examples/angular/basic/README.md @@ -2,5 +2,5 @@ To run this example: -- `npm install` or `yarn` or `pnpm i` -- `npm run start` or `yarn start` or `pnpm start` +- `npm install` or `yarn` or `pnpm i` or `bun i` +- `npm run start` or `yarn start` or `pnpm start` or `bun start` diff --git a/examples/angular/infinite-query-with-max-pages/README.md b/examples/angular/infinite-query-with-max-pages/README.md index a6d17381b3..1d8b6e7182 100644 --- a/examples/angular/infinite-query-with-max-pages/README.md +++ b/examples/angular/infinite-query-with-max-pages/README.md @@ -2,5 +2,5 @@ To run this example: -- `npm install` or `yarn` or `pnpm i` -- `npm run start` or `yarn start` or `pnpm start` +- `npm install` or `yarn` or `pnpm i` or `bun i` +- `npm run start` or `yarn start` or `pnpm start` or `bun start` diff --git a/examples/angular/router/README.md b/examples/angular/router/README.md index 3c0e5e73f2..129bb7bda8 100644 --- a/examples/angular/router/README.md +++ b/examples/angular/router/README.md @@ -2,5 +2,5 @@ To run this example: -- `npm install` or `yarn` or `pnpm i` -- `npm run start` or `yarn start` or `pnpm start` +- `npm install` or `yarn` or `pnpm i` or `bun i` +- `npm run start` or `yarn start` or `pnpm start` or `bun start` diff --git a/examples/angular/simple/README.md b/examples/angular/simple/README.md index cddff73343..c329cad361 100644 --- a/examples/angular/simple/README.md +++ b/examples/angular/simple/README.md @@ -2,5 +2,5 @@ To run this example: -- `npm install` or `yarn` or `pnpm i` -- `npm run start` or `yarn start` or `pnpm start` +- `npm install` or `yarn` or `pnpm i` or `bun i` +- `npm run start` or `yarn start` or `pnpm start` or `bun start` diff --git a/examples/svelte/auto-refetching/README.md b/examples/svelte/auto-refetching/README.md index 5c91169b0c..006bfde64c 100644 --- a/examples/svelte/auto-refetching/README.md +++ b/examples/svelte/auto-refetching/README.md @@ -16,7 +16,7 @@ npm create svelte@latest my-app ## Developing -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: +Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn` or `bun install`), start a development server: ```bash npm run dev diff --git a/examples/svelte/basic/README.md b/examples/svelte/basic/README.md index 5c91169b0c..006bfde64c 100644 --- a/examples/svelte/basic/README.md +++ b/examples/svelte/basic/README.md @@ -16,7 +16,7 @@ npm create svelte@latest my-app ## Developing -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: +Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn` or `bun install`), start a development server: ```bash npm run dev diff --git a/examples/svelte/load-more-infinite-scroll/README.md b/examples/svelte/load-more-infinite-scroll/README.md index 5c91169b0c..006bfde64c 100644 --- a/examples/svelte/load-more-infinite-scroll/README.md +++ b/examples/svelte/load-more-infinite-scroll/README.md @@ -16,7 +16,7 @@ npm create svelte@latest my-app ## Developing -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: +Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn` or `bun install`), start a development server: ```bash npm run dev diff --git a/examples/svelte/optimistic-updates-typescript/README.md b/examples/svelte/optimistic-updates-typescript/README.md index 5c91169b0c..006bfde64c 100644 --- a/examples/svelte/optimistic-updates-typescript/README.md +++ b/examples/svelte/optimistic-updates-typescript/README.md @@ -16,7 +16,7 @@ npm create svelte@latest my-app ## Developing -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: +Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn` or `bun install`), start a development server: ```bash npm run dev diff --git a/examples/svelte/ssr/README.md b/examples/svelte/ssr/README.md index 5c91169b0c..006bfde64c 100644 --- a/examples/svelte/ssr/README.md +++ b/examples/svelte/ssr/README.md @@ -16,7 +16,7 @@ npm create svelte@latest my-app ## Developing -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: +Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn` or `bun install`), start a development server: ```bash npm run dev diff --git a/examples/vue/2.6-basic/README.md b/examples/vue/2.6-basic/README.md index 975cba03de..b7be0e933b 100644 --- a/examples/vue/2.6-basic/README.md +++ b/examples/vue/2.6-basic/README.md @@ -2,5 +2,5 @@ To run this example: -- `npm install` or `yarn` or `pnpm i` -- `npm run dev` or `yarn dev` or `pnpm dev` +- `npm install` or `yarn` or `pnpm i` or `bun i` +- `npm run dev` or `yarn dev` or `pnpm dev` or `bun dev` diff --git a/examples/vue/basic/README.md b/examples/vue/basic/README.md index 28462a4ad2..a9aad379b0 100644 --- a/examples/vue/basic/README.md +++ b/examples/vue/basic/README.md @@ -2,5 +2,5 @@ To run this example: -- `npm install` or `yarn` or `pnpm i` -- `npm run dev` or `yarn dev` or `pnpm dev` +- `npm install` or `yarn` or `pnpm i` or `bun i` +- `npm run dev` or `yarn dev` or `pnpm dev` or `bun dev` diff --git a/examples/vue/simple/README.md b/examples/vue/simple/README.md index 28462a4ad2..a9aad379b0 100644 --- a/examples/vue/simple/README.md +++ b/examples/vue/simple/README.md @@ -2,5 +2,5 @@ To run this example: -- `npm install` or `yarn` or `pnpm i` -- `npm run dev` or `yarn dev` or `pnpm dev` +- `npm install` or `yarn` or `pnpm i` or `bun i` +- `npm run dev` or `yarn dev` or `pnpm dev` or `bun dev` diff --git a/packages/angular-query-experimental/README.md b/packages/angular-query-experimental/README.md index 02354a8e76..4fdf0fb277 100644 --- a/packages/angular-query-experimental/README.md +++ b/packages/angular-query-experimental/README.md @@ -39,6 +39,8 @@ Visit https://tanstack.com/query/latest/docs/angular/overview $ pnpm add @tanstack/angular-query-experimental # or $ yarn add @tanstack/angular-query-experimental + # or + $ bun add @tanstack/angular-query-experimental ``` 2. Initialize **Angular Query** by adding **provideAngularQuery** to your application diff --git a/packages/vue-query/README.md b/packages/vue-query/README.md index 867d01a0e7..55b30fda35 100644 --- a/packages/vue-query/README.md +++ b/packages/vue-query/README.md @@ -40,6 +40,8 @@ Visit https://tanstack.com/query/latest/docs/vue/overview $ pnpm add @tanstack/vue-query # or $ yarn add @tanstack/vue-query + # or + $ bun add @tanstack/vue-query ``` > If you are using Vue 2.6, make sure to also setup [@vue/composition-api](https://github.com/vuejs/composition-api) From 55782aebbbc69020858f8ed611ab41d24eee215a Mon Sep 17 00:00:00 2001 From: Dominik Dorfmeister Date: Mon, 26 Feb 2024 08:53:01 +0100 Subject: [PATCH 06/10] chore: fix lint --- docs/eslint/eslint-plugin-query.md | 2 +- docs/framework/solid/devtools.md | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/eslint/eslint-plugin-query.md b/docs/eslint/eslint-plugin-query.md index 20e5d8a30d..661943b8b9 100644 --- a/docs/eslint/eslint-plugin-query.md +++ b/docs/eslint/eslint-plugin-query.md @@ -15,7 +15,7 @@ $ npm i -D @tanstack/eslint-plugin-query $ pnpm add -D @tanstack/eslint-plugin-query # or $ yarn add -D @tanstack/eslint-plugin-query -# or +# or $ bun add -D @tanstack/eslint-plugin-query ``` diff --git a/docs/framework/solid/devtools.md b/docs/framework/solid/devtools.md index 78a46db216..58493492d8 100644 --- a/docs/framework/solid/devtools.md +++ b/docs/framework/solid/devtools.md @@ -23,7 +23,6 @@ $ yarn add @tanstack/solid-query-devtools $ bun add @tanstack/solid-query-devtools ``` - You can import the devtools like this: ```tsx From d82c83e5901a233592bc55c0a1286ea749b03598 Mon Sep 17 00:00:00 2001 From: HJZzzzz <44113416+HJZzzzz@users.noreply.github.com> Date: Tue, 27 Feb 2024 18:04:22 +0800 Subject: [PATCH 07/10] fix(react-query): remove placeholderData from suspense query (#6973) Co-authored-by: Huang Jingzhan --- .../src/__tests__/suspense.test.tsx | 102 ++++++++++++++++++ .../react-query/src/useSuspenseQueries.ts | 1 + packages/react-query/src/useSuspenseQuery.ts | 1 + 3 files changed, 104 insertions(+) diff --git a/packages/react-query/src/__tests__/suspense.test.tsx b/packages/react-query/src/__tests__/suspense.test.tsx index af5c54b322..64b1b91fb3 100644 --- a/packages/react-query/src/__tests__/suspense.test.tsx +++ b/packages/react-query/src/__tests__/suspense.test.tsx @@ -779,6 +779,58 @@ describe('useSuspenseQuery', () => { consoleMock.mockRestore() }) + + it('should still suspense if queryClient has placeholderData config', async () => { + const key = queryKey() + const queryClientWithPlaceholder = createQueryClient({ + defaultOptions: { + queries: { + placeholderData: (previousData: any) => previousData, + }, + }, + }) + const states: Array> = [] + + let count = 0 + let renders = 0 + + function Page() { + renders++ + + const [stateKey, setStateKey] = React.useState(key) + + const state = useSuspenseQuery({ + queryKey: stateKey, + queryFn: async () => { + count++ + await sleep(100) + return count + }, + }) + + states.push(state) + + return ( +
+
+ ) + } + + const rendered = renderWithClient( + queryClientWithPlaceholder, + + + , + ) + await waitFor(() => rendered.getByText('loading')) + await waitFor(() => rendered.getByText('data: 1')) + fireEvent.click(rendered.getByLabelText('toggle')) + + await waitFor(() => rendered.getByText('loading')) + await waitFor(() => rendered.getByText('data: 2')) + }) }) describe('useSuspenseQueries', () => { @@ -1090,4 +1142,54 @@ describe('useSuspenseQueries', () => { expect(queryFnCount).toBe(2) }) + + it('should still suspense if queryClient has placeholderData config', async () => { + const key = queryKey() + const queryClientWithPlaceholder = createQueryClient({ + defaultOptions: { + queries: { + placeholderData: (previousData: any) => previousData, + }, + }, + }) + + function Page() { + const [count, setCount] = React.useState(0) + const [isPending, startTransition] = React.useTransition() + const { data } = useSuspenseQuery({ + queryKey: [key, count], + queryFn: async () => { + await sleep(10) + return 'data' + count + }, + }) + + return ( +
+ + +
{isPending ? 'Pending...' : String(data)}
+
+ ) + } + + const rendered = renderWithClient( + queryClientWithPlaceholder, + + + , + ) + + await waitFor(() => rendered.getByText('Loading...')) + + await waitFor(() => rendered.getByText('data0')) + + fireEvent.click(rendered.getByText('inc')) + + await waitFor(() => rendered.getByText('Pending...')) + + await waitFor(() => rendered.getByText('data1')) + }) }) diff --git a/packages/react-query/src/useSuspenseQueries.ts b/packages/react-query/src/useSuspenseQueries.ts index ead3dd35da..1d58da0c53 100644 --- a/packages/react-query/src/useSuspenseQueries.ts +++ b/packages/react-query/src/useSuspenseQueries.ts @@ -187,6 +187,7 @@ export function useSuspenseQueries< suspense: true, throwOnError: defaultThrowOnError, enabled: true, + placeholderData: undefined, })), } as any, queryClient, diff --git a/packages/react-query/src/useSuspenseQuery.ts b/packages/react-query/src/useSuspenseQuery.ts index 179f58392a..3bf6039d01 100644 --- a/packages/react-query/src/useSuspenseQuery.ts +++ b/packages/react-query/src/useSuspenseQuery.ts @@ -20,6 +20,7 @@ export function useSuspenseQuery< enabled: true, suspense: true, throwOnError: defaultThrowOnError, + placeholderData: undefined, }, QueryObserver, queryClient, From be2bf30718da109787fb962958a03d2b373f0350 Mon Sep 17 00:00:00 2001 From: Jonghyeon Ko Date: Tue, 27 Feb 2024 21:50:37 +0900 Subject: [PATCH 08/10] test(react-query-devtools): add test case for not in `process.env.NODE_ENV='development'` (#6940) * test(react-query-devtools): add test case for production mode * chore: update * chore: update --------- Co-authored-by: Dominik Dorfmeister --- .../src/__tests__/not-development.test.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 packages/react-query-devtools/src/__tests__/not-development.test.tsx diff --git a/packages/react-query-devtools/src/__tests__/not-development.test.tsx b/packages/react-query-devtools/src/__tests__/not-development.test.tsx new file mode 100644 index 0000000000..6353147ed4 --- /dev/null +++ b/packages/react-query-devtools/src/__tests__/not-development.test.tsx @@ -0,0 +1,9 @@ +import { describe, expect, it } from 'vitest' +import { ReactQueryDevtools } from '..' + +describe('ReactQueryDevtools not in process.env.NODE_ENV=development', () => { + it('should return null', () => { + expect(process.env.NODE_ENV).not.toBe('development') + expect(ReactQueryDevtools({})).toBeNull() + }) +}) From 6b9673692bd579f42aaef8e818627f90c15190a6 Mon Sep 17 00:00:00 2001 From: Jonghyeon Ko Date: Wed, 28 Feb 2024 05:47:19 +0900 Subject: [PATCH 09/10] ci(react-query): resolve `test:lib` error (#6979) * ci(react-query): resolve error * test(react-query): update useMutation.test.tsx * chore: format --- packages/react-query/src/__tests__/useMutation.test.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react-query/src/__tests__/useMutation.test.tsx b/packages/react-query/src/__tests__/useMutation.test.tsx index e5f0f3f44c..d162f3ab17 100644 --- a/packages/react-query/src/__tests__/useMutation.test.tsx +++ b/packages/react-query/src/__tests__/useMutation.test.tsx @@ -1138,6 +1138,8 @@ describe('useMutation', () => { fireEvent.click(rendered.getByRole('button', { name: /mutate/i })) - await rendered.findByText('data: custom client, status: success') + await waitFor(() => + rendered.findByText('data: custom client, status: success'), + ) }) }) From 18c2caedda76764015a3f8bfcb09ce854e9a9df7 Mon Sep 17 00:00:00 2001 From: Jonghyeon Ko Date: Wed, 28 Feb 2024 16:20:33 +0900 Subject: [PATCH 10/10] test(react-query): use vitest typecheck correctly with *.test-d.ts (#6978) --- package.json | 4 +- .../__tests__/infiniteQueryOptions.test-d.tsx | 142 +++++++++++ .../infiniteQueryOptions.types.test.tsx | 177 -------------- .../src/__tests__/queryOptions.test-d.tsx | 140 +++++++++++ .../src/__tests__/queryOptions.types.test.tsx | 192 --------------- .../src/__tests__/suspense.test-d.tsx | 124 ++++++++++ .../src/__tests__/suspense.types.test.tsx | 147 ------------ .../src/__tests__/useInfiniteQuery.test-d.tsx | 140 +++++++++++ .../__tests__/useInfiniteQuery.type.test.tsx | 224 ------------------ .../src/__tests__/useQueries.test-d.tsx | 126 ++++++++++ .../src/__tests__/useQueries.types.test.tsx | 148 ------------ .../src/__tests__/useQuery.test-d.tsx | 140 +++++++++++ .../src/__tests__/useQuery.types.test.tsx | 179 -------------- packages/react-query/src/__tests__/utils.tsx | 8 - pnpm-lock.yaml | 90 +++---- 15 files changed, 864 insertions(+), 1117 deletions(-) create mode 100644 packages/react-query/src/__tests__/infiniteQueryOptions.test-d.tsx delete mode 100644 packages/react-query/src/__tests__/infiniteQueryOptions.types.test.tsx create mode 100644 packages/react-query/src/__tests__/queryOptions.test-d.tsx delete mode 100644 packages/react-query/src/__tests__/queryOptions.types.test.tsx create mode 100644 packages/react-query/src/__tests__/suspense.test-d.tsx delete mode 100644 packages/react-query/src/__tests__/suspense.types.test.tsx create mode 100644 packages/react-query/src/__tests__/useInfiniteQuery.test-d.tsx delete mode 100644 packages/react-query/src/__tests__/useInfiniteQuery.type.test.tsx create mode 100644 packages/react-query/src/__tests__/useQueries.test-d.tsx delete mode 100644 packages/react-query/src/__tests__/useQueries.types.test.tsx create mode 100644 packages/react-query/src/__tests__/useQuery.test-d.tsx delete mode 100644 packages/react-query/src/__tests__/useQuery.types.test.tsx diff --git a/package.json b/package.json index 33173dbbc6..31e80ca29b 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@types/react-dom": "^18.2.19", "@typescript-eslint/eslint-plugin": "^6.20.0", "@typescript-eslint/parser": "^6.20.0", - "@vitest/coverage-istanbul": "^1.2.2", + "@vitest/coverage-istanbul": "^1.3.1", "cpy-cli": "^5.0.0", "esbuild-plugin-file-path-extensions": "^2.0.0", "eslint": "^8.56.0", @@ -73,7 +73,7 @@ "tsup": "^8.0.1", "typescript": "5.2.2", "vite": "^5.1.1", - "vitest": "^1.2.2" + "vitest": "^1.3.1" }, "pnpm": { "overrides": { diff --git a/packages/react-query/src/__tests__/infiniteQueryOptions.test-d.tsx b/packages/react-query/src/__tests__/infiniteQueryOptions.test-d.tsx new file mode 100644 index 0000000000..434f5fb48c --- /dev/null +++ b/packages/react-query/src/__tests__/infiniteQueryOptions.test-d.tsx @@ -0,0 +1,142 @@ +import { describe, expectTypeOf, it } from 'vitest' +import { QueryClient } from '@tanstack/query-core' +import { infiniteQueryOptions } from '../infiniteQueryOptions' +import { useInfiniteQuery } from '../useInfiniteQuery' +import { useSuspenseInfiniteQuery } from '../useSuspenseInfiniteQuery' +import type { InfiniteData, dataTagSymbol } from '@tanstack/query-core' + +describe('queryOptions', () => { + it('should not allow excess properties', () => { + infiniteQueryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve('data'), + getNextPageParam: () => 1, + initialPageParam: 1, + // @ts-expect-error this is a good error, because stallTime does not exist! + stallTime: 1000, + }) + }) + it('should infer types for callbacks', () => { + infiniteQueryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve('data'), + staleTime: 1000, + getNextPageParam: () => 1, + initialPageParam: 1, + select: (data) => { + expectTypeOf(data).toEqualTypeOf>() + }, + }) + }) + it('should work when passed to useInfiniteQuery', () => { + const options = infiniteQueryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve('string'), + getNextPageParam: () => 1, + initialPageParam: 1, + }) + + const { data } = useInfiniteQuery(options) + + // known issue: type of pageParams is unknown when returned from useInfiniteQuery + expectTypeOf(data).toEqualTypeOf< + InfiniteData | undefined + >() + }) + it('should work when passed to useSuspenseInfiniteQuery', () => { + const options = infiniteQueryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve('string'), + getNextPageParam: () => 1, + initialPageParam: 1, + }) + + const { data } = useSuspenseInfiniteQuery(options) + + expectTypeOf(data).toEqualTypeOf>() + }) + it('should work when passed to fetchInfiniteQuery', async () => { + const options = infiniteQueryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve('string'), + getNextPageParam: () => 1, + initialPageParam: 1, + }) + + const data = await new QueryClient().fetchInfiniteQuery(options) + + expectTypeOf(data).toEqualTypeOf>() + }) + it('should tag the queryKey with the result type of the QueryFn', () => { + const { queryKey } = infiniteQueryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve('string'), + getNextPageParam: () => 1, + initialPageParam: 1, + }) + + expectTypeOf<(typeof queryKey)[typeof dataTagSymbol]>().toEqualTypeOf< + InfiniteData + >() + }) + it('should tag the queryKey even if no promise is returned', () => { + const { queryKey } = infiniteQueryOptions({ + queryKey: ['key'], + queryFn: () => 'string', + getNextPageParam: () => 1, + initialPageParam: 1, + }) + + expectTypeOf<(typeof queryKey)[typeof dataTagSymbol]>().toEqualTypeOf< + InfiniteData + >() + }) + it('should tag the queryKey with the result type of the QueryFn if select is used', () => { + const { queryKey } = infiniteQueryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve('string'), + select: (data) => data.pages, + getNextPageParam: () => 1, + initialPageParam: 1, + }) + + expectTypeOf<(typeof queryKey)[typeof dataTagSymbol]>().toEqualTypeOf< + InfiniteData + >() + }) + it('should return the proper type when passed to getQueryData', () => { + const { queryKey } = infiniteQueryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve('string'), + getNextPageParam: () => 1, + initialPageParam: 1, + }) + + const queryClient = new QueryClient() + const data = queryClient.getQueryData(queryKey) + + expectTypeOf(data).toEqualTypeOf< + InfiniteData | undefined + >() + }) + it('should properly type when passed to setQueryData', () => { + const { queryKey } = infiniteQueryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve('string'), + getNextPageParam: () => 1, + initialPageParam: 1, + }) + + const queryClient = new QueryClient() + const data = queryClient.setQueryData(queryKey, (prev) => { + expectTypeOf(prev).toEqualTypeOf< + InfiniteData | undefined + >() + return prev + }) + + expectTypeOf(data).toEqualTypeOf< + InfiniteData | undefined + >() + }) +}) diff --git a/packages/react-query/src/__tests__/infiniteQueryOptions.types.test.tsx b/packages/react-query/src/__tests__/infiniteQueryOptions.types.test.tsx deleted file mode 100644 index 0bf8fcc579..0000000000 --- a/packages/react-query/src/__tests__/infiniteQueryOptions.types.test.tsx +++ /dev/null @@ -1,177 +0,0 @@ -import { describe, it } from 'vitest' -import { QueryClient } from '@tanstack/query-core' -import { infiniteQueryOptions } from '../infiniteQueryOptions' -import { useInfiniteQuery } from '../useInfiniteQuery' -import { useSuspenseInfiniteQuery } from '../useSuspenseInfiniteQuery' -import { doNotExecute } from './utils' -import type { InfiniteData, dataTagSymbol } from '@tanstack/query-core' -import type { Equal, Expect } from './utils' - -describe('queryOptions', () => { - it('should not allow excess properties', () => { - doNotExecute(() => { - return infiniteQueryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve('data'), - getNextPageParam: () => 1, - initialPageParam: 1, - // @ts-expect-error this is a good error, because stallTime does not exist! - stallTime: 1000, - }) - }) - }) - it('should infer types for callbacks', () => { - doNotExecute(() => { - return infiniteQueryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve('data'), - staleTime: 1000, - getNextPageParam: () => 1, - initialPageParam: 1, - select: (data) => { - const result: Expect< - Equal, typeof data> - > = true - return result - }, - }) - }) - }) - it('should work when passed to useInfiniteQuery', () => { - doNotExecute(() => { - const options = infiniteQueryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve('string'), - getNextPageParam: () => 1, - initialPageParam: 1, - }) - - const { data } = useInfiniteQuery(options) - - // known issue: type of pageParams is unknown when returned from useInfiniteQuery - const result: Expect< - Equal | undefined> - > = true - return result - }) - }) - it('should work when passed to useSuspenseInfiniteQuery', () => { - doNotExecute(() => { - const options = infiniteQueryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve('string'), - getNextPageParam: () => 1, - initialPageParam: 1, - }) - - const { data } = useSuspenseInfiniteQuery(options) - - const result: Expect>> = - true - return result - }) - }) - it('should work when passed to fetchInfiniteQuery', () => { - doNotExecute(async () => { - const options = infiniteQueryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve('string'), - getNextPageParam: () => 1, - initialPageParam: 1, - }) - - const data = await new QueryClient().fetchInfiniteQuery(options) - - const result: Expect>> = - true - return result - }) - }) - it('should tag the queryKey with the result type of the QueryFn', () => { - doNotExecute(() => { - const { queryKey } = infiniteQueryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve('string'), - getNextPageParam: () => 1, - initialPageParam: 1, - }) - - const result: Expect< - Equal<(typeof queryKey)[typeof dataTagSymbol], InfiniteData> - > = true - return result - }) - }) - it('should tag the queryKey even if no promise is returned', () => { - doNotExecute(() => { - const { queryKey } = infiniteQueryOptions({ - queryKey: ['key'], - queryFn: () => 'string', - getNextPageParam: () => 1, - initialPageParam: 1, - }) - - const result: Expect< - Equal<(typeof queryKey)[typeof dataTagSymbol], InfiniteData> - > = true - return result - }) - }) - it('should tag the queryKey with the result type of the QueryFn if select is used', () => { - doNotExecute(() => { - const { queryKey } = infiniteQueryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve('string'), - select: (data) => data.pages, - getNextPageParam: () => 1, - initialPageParam: 1, - }) - - const result: Expect< - Equal<(typeof queryKey)[typeof dataTagSymbol], InfiniteData> - > = true - return result - }) - }) - it('should return the proper type when passed to getQueryData', () => { - doNotExecute(() => { - const { queryKey } = infiniteQueryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve('string'), - getNextPageParam: () => 1, - initialPageParam: 1, - }) - - const queryClient = new QueryClient() - const data = queryClient.getQueryData(queryKey) - - const result: Expect< - Equal | undefined> - > = true - return result - }) - }) - it('should properly type when passed to setQueryData', () => { - doNotExecute(() => { - const { queryKey } = infiniteQueryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve('string'), - getNextPageParam: () => 1, - initialPageParam: 1, - }) - - const queryClient = new QueryClient() - const data = queryClient.setQueryData(queryKey, (prev) => { - const result: Expect< - Equal | undefined> - > = true - return result ? prev : { pages: ['foo'], pageParams: [1] } - }) - - const result: Expect< - Equal | undefined> - > = true - return result - }) - }) -}) diff --git a/packages/react-query/src/__tests__/queryOptions.test-d.tsx b/packages/react-query/src/__tests__/queryOptions.test-d.tsx new file mode 100644 index 0000000000..23259bc169 --- /dev/null +++ b/packages/react-query/src/__tests__/queryOptions.test-d.tsx @@ -0,0 +1,140 @@ +import { describe, expect, expectTypeOf, it } from 'vitest' +import { QueryClient } from '@tanstack/query-core' +import { dataTagSymbol } from '@tanstack/query-core' +import { queryOptions } from '../queryOptions' +import { useQuery } from '../useQuery' +import { useQueries } from '../useQueries' +import { useSuspenseQuery } from '../useSuspenseQuery' + +describe('queryOptions', () => { + it('should not allow excess properties', () => { + queryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + // @ts-expect-error this is a good error, because stallTime does not exist! + stallTime: 1000, + }) + }) + it('should infer types for callbacks', () => { + queryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + staleTime: 1000, + select: (data) => { + expectTypeOf(data).toEqualTypeOf() + }, + }) + }) + it('should work when passed to useQuery', () => { + const options = queryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + }) + + const { data } = useQuery(options) + expectTypeOf(data).toEqualTypeOf() + }) + it('should work when passed to useSuspenseQuery', () => { + const options = queryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + }) + + const { data } = useSuspenseQuery(options) + expectTypeOf(data).toEqualTypeOf() + }) + it('should work when passed to fetchQuery', async () => { + const options = queryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + }) + + const data = await new QueryClient().fetchQuery(options) + expectTypeOf(data).toEqualTypeOf() + }) + it('should work when passed to useQueries', () => { + const options = queryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + }) + + const [{ data }] = useQueries({ + queries: [options], + }) + + expectTypeOf(data).toEqualTypeOf() + }) + it('should tag the queryKey with the result type of the QueryFn', () => { + expect(() => { + const { queryKey } = queryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + }) + + expectTypeOf(queryKey[dataTagSymbol]).toEqualTypeOf() + }) + }) + it('should tag the queryKey even if no promise is returned', () => { + const { queryKey } = queryOptions({ + queryKey: ['key'], + queryFn: () => 5, + }) + + expectTypeOf(queryKey[dataTagSymbol]).toEqualTypeOf() + }) + it('should tag the queryKey with unknown if there is no queryFn', () => { + const { queryKey } = queryOptions({ + queryKey: ['key'], + }) + + expectTypeOf(queryKey[dataTagSymbol]).toEqualTypeOf() + }) + it('should tag the queryKey with the result type of the QueryFn if select is used', () => { + const { queryKey } = queryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + select: (data) => data.toString(), + }) + + expectTypeOf(queryKey[dataTagSymbol]).toEqualTypeOf() + }) + it('should return the proper type when passed to getQueryData', () => { + const { queryKey } = queryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + }) + + const queryClient = new QueryClient() + const data = queryClient.getQueryData(queryKey) + expectTypeOf(data).toEqualTypeOf() + }) + it('should properly type updaterFn when passed to setQueryData', () => { + const { queryKey } = queryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + }) + + const queryClient = new QueryClient() + const data = queryClient.setQueryData(queryKey, (prev) => { + expectTypeOf(prev).toEqualTypeOf() + return prev + }) + expectTypeOf(data).toEqualTypeOf() + }) + it('should properly type value when passed to setQueryData', () => { + const { queryKey } = queryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + }) + + const queryClient = new QueryClient() + + // @ts-expect-error value should be a number + queryClient.setQueryData(queryKey, '5') + // @ts-expect-error value should be a number + queryClient.setQueryData(queryKey, () => '5') + + const data = queryClient.setQueryData(queryKey, 5) + expectTypeOf(data).toEqualTypeOf() + }) +}) diff --git a/packages/react-query/src/__tests__/queryOptions.types.test.tsx b/packages/react-query/src/__tests__/queryOptions.types.test.tsx deleted file mode 100644 index f15234ec59..0000000000 --- a/packages/react-query/src/__tests__/queryOptions.types.test.tsx +++ /dev/null @@ -1,192 +0,0 @@ -import { describe, it } from 'vitest' -import { QueryClient } from '@tanstack/query-core' -import { queryOptions } from '../queryOptions' -import { useQuery } from '../useQuery' -import { useQueries } from '../useQueries' -import { useSuspenseQuery } from '../useSuspenseQuery' -import { doNotExecute } from './utils' -import type { dataTagSymbol } from '@tanstack/query-core' -import type { Equal, Expect } from './utils' - -describe('queryOptions', () => { - it('should not allow excess properties', () => { - doNotExecute(() => { - return queryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - // @ts-expect-error this is a good error, because stallTime does not exist! - stallTime: 1000, - }) - }) - }) - it('should infer types for callbacks', () => { - doNotExecute(() => { - return queryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - staleTime: 1000, - select: (data) => { - const result: Expect> = true - return result - }, - }) - }) - }) - it('should work when passed to useQuery', () => { - doNotExecute(() => { - const options = queryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - }) - - const { data } = useQuery(options) - - const result: Expect> = true - return result - }) - }) - it('should work when passed to useSuspenseQuery', () => { - doNotExecute(() => { - const options = queryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - }) - - const { data } = useSuspenseQuery(options) - - const result: Expect> = true - return result - }) - }) - it('should work when passed to fetchQuery', () => { - doNotExecute(async () => { - const options = queryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - }) - - const data = await new QueryClient().fetchQuery(options) - - const result: Expect> = true - return result - }) - }) - it('should work when passed to useQueries', () => { - doNotExecute(() => { - const options = queryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - }) - - const [{ data }] = useQueries({ - queries: [options], - }) - - const result: Expect> = true - return result - }) - }) - it('should tag the queryKey with the result type of the QueryFn', () => { - doNotExecute(() => { - const { queryKey } = queryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - }) - - const result: Expect< - Equal<(typeof queryKey)[typeof dataTagSymbol], number> - > = true - return result - }) - }) - it('should tag the queryKey even if no promise is returned', () => { - doNotExecute(() => { - const { queryKey } = queryOptions({ - queryKey: ['key'], - queryFn: () => 5, - }) - - const result: Expect< - Equal<(typeof queryKey)[typeof dataTagSymbol], number> - > = true - return result - }) - }) - it('should tag the queryKey with unknown if there is no queryFn', () => { - doNotExecute(() => { - const { queryKey } = queryOptions({ - queryKey: ['key'], - }) - - const result: Expect< - Equal<(typeof queryKey)[typeof dataTagSymbol], unknown> - > = true - return result - }) - }) - it('should tag the queryKey with the result type of the QueryFn if select is used', () => { - doNotExecute(() => { - const { queryKey } = queryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - select: (data) => data.toString(), - }) - - const result: Expect< - Equal<(typeof queryKey)[typeof dataTagSymbol], number> - > = true - return result - }) - }) - it('should return the proper type when passed to getQueryData', () => { - doNotExecute(() => { - const { queryKey } = queryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - }) - - const queryClient = new QueryClient() - const data = queryClient.getQueryData(queryKey) - - const result: Expect> = true - return result - }) - }) - it('should properly type updaterFn when passed to setQueryData', () => { - doNotExecute(() => { - const { queryKey } = queryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - }) - - const queryClient = new QueryClient() - const data = queryClient.setQueryData(queryKey, (prev) => { - const result: Expect> = true - return result ? prev : 1 - }) - - const result: Expect> = true - return result - }) - }) - it('should properly type value when passed to setQueryData', () => { - doNotExecute(() => { - const { queryKey } = queryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - }) - - const queryClient = new QueryClient() - - // @ts-expect-error value should be a number - queryClient.setQueryData(queryKey, '5') - // @ts-expect-error value should be a number - queryClient.setQueryData(queryKey, () => '5') - - const data = queryClient.setQueryData(queryKey, 5) - - const result: Expect> = true - return result - }) - }) -}) diff --git a/packages/react-query/src/__tests__/suspense.test-d.tsx b/packages/react-query/src/__tests__/suspense.test-d.tsx new file mode 100644 index 0000000000..9367866753 --- /dev/null +++ b/packages/react-query/src/__tests__/suspense.test-d.tsx @@ -0,0 +1,124 @@ +import { describe, expectTypeOf, it } from 'vitest' +import { useSuspenseQuery } from '../useSuspenseQuery' +import { useSuspenseInfiniteQuery } from '../useSuspenseInfiniteQuery' +import type { InfiniteData } from '@tanstack/query-core' + +describe('useSuspenseQuery', () => { + it('should always have data defined', () => { + const { data } = useSuspenseQuery({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + }) + + expectTypeOf(data).toEqualTypeOf() + }) + + it('should not have pending status', () => { + const { status } = useSuspenseQuery({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + }) + + expectTypeOf(status).toEqualTypeOf<'error' | 'success'>() + }) + + it('should not allow placeholderData, enabled or throwOnError props', () => { + useSuspenseQuery({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + // @ts-expect-error TS2345 + placeholderData: 5, + enabled: true, + }) + + useSuspenseQuery({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + // @ts-expect-error TS2345 + enabled: true, + }) + + useSuspenseQuery({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + // @ts-expect-error TS2345 + throwOnError: true, + }) + }) + + it('should not return isPlaceholderData', () => { + const query = useSuspenseQuery({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + }) + + // @ts-expect-error TS2339 + query.isPlaceholderData + }) +}) + +describe('useSuspenseInfiniteQuery', () => { + it('should always have data defined', () => { + const { data } = useSuspenseInfiniteQuery({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + initialPageParam: 1, + getNextPageParam: () => 1, + }) + + expectTypeOf(data).toEqualTypeOf>() + }) + + it('should not have pending status', () => { + const { status } = useSuspenseInfiniteQuery({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + initialPageParam: 1, + getNextPageParam: () => 1, + }) + + expectTypeOf(status).toEqualTypeOf<'error' | 'success'>() + }) + + it('should not allow placeholderData, enabled or throwOnError props', () => { + useSuspenseInfiniteQuery({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + initialPageParam: 1, + getNextPageParam: () => 1, + // @ts-expect-error TS2345 + placeholderData: 5, + enabled: true, + }) + + useSuspenseInfiniteQuery({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + initialPageParam: 1, + getNextPageParam: () => 1, + // @ts-expect-error TS2345 + enabled: true, + }) + + useSuspenseInfiniteQuery({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + initialPageParam: 1, + getNextPageParam: () => 1, + // @ts-expect-error TS2345 + throwOnError: true, + }) + }) + + it('should not return isPlaceholderData', () => { + const query = useSuspenseInfiniteQuery({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + initialPageParam: 1, + getNextPageParam: () => 1, + }) + + // @ts-expect-error TS2339 + query.isPlaceholderData + }) +}) diff --git a/packages/react-query/src/__tests__/suspense.types.test.tsx b/packages/react-query/src/__tests__/suspense.types.test.tsx deleted file mode 100644 index 6afb9aaaeb..0000000000 --- a/packages/react-query/src/__tests__/suspense.types.test.tsx +++ /dev/null @@ -1,147 +0,0 @@ -import { describe, it } from 'vitest' -import { useSuspenseQuery } from '../useSuspenseQuery' -import { useSuspenseInfiniteQuery } from '../useSuspenseInfiniteQuery' -import { doNotExecute } from './utils' -import type { InfiniteData } from '@tanstack/query-core' -import type { Equal, Expect } from './utils' - -describe('useSuspenseQuery', () => { - it('should always have data defined', () => { - doNotExecute(() => { - const { data } = useSuspenseQuery({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - }) - - const result: Expect> = true - return result - }) - }) - - it('should not have pending status', () => { - doNotExecute(() => { - const { status } = useSuspenseQuery({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - }) - - const result: Expect> = true - return result - }) - }) - - it('should not allow placeholderData, enabled or throwOnError props', () => { - doNotExecute(() => { - useSuspenseQuery({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - // @ts-expect-error TS2345 - placeholderData: 5, - enabled: true, - }) - - useSuspenseQuery({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - // @ts-expect-error TS2345 - enabled: true, - }) - - useSuspenseQuery({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - // @ts-expect-error TS2345 - throwOnError: true, - }) - }) - }) - - it('should not return isPlaceholderData', () => { - doNotExecute(() => { - const query = useSuspenseQuery({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - }) - - // @ts-expect-error TS2339 - void query.isPlaceholderData - }) - }) -}) - -describe('useSuspenseInfiniteQuery', () => { - it('should always have data defined', () => { - doNotExecute(() => { - const { data } = useSuspenseInfiniteQuery({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - initialPageParam: 1, - getNextPageParam: () => 1, - }) - - const result: Expect>> = - true - return result - }) - }) - - it('should not have pending status', () => { - doNotExecute(() => { - const { status } = useSuspenseInfiniteQuery({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - initialPageParam: 1, - getNextPageParam: () => 1, - }) - - const result: Expect> = true - return result - }) - }) - - it('should not allow placeholderData, enabled or throwOnError props', () => { - doNotExecute(() => { - useSuspenseInfiniteQuery({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - initialPageParam: 1, - getNextPageParam: () => 1, - // @ts-expect-error TS2345 - placeholderData: 5, - enabled: true, - }) - - useSuspenseInfiniteQuery({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - initialPageParam: 1, - getNextPageParam: () => 1, - // @ts-expect-error TS2345 - enabled: true, - }) - - useSuspenseInfiniteQuery({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - initialPageParam: 1, - getNextPageParam: () => 1, - // @ts-expect-error TS2345 - throwOnError: true, - }) - }) - }) - - it('should not return isPlaceholderData', () => { - doNotExecute(() => { - const query = useSuspenseInfiniteQuery({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - initialPageParam: 1, - getNextPageParam: () => 1, - }) - - // @ts-expect-error TS2339 - void query.isPlaceholderData - }) - }) -}) diff --git a/packages/react-query/src/__tests__/useInfiniteQuery.test-d.tsx b/packages/react-query/src/__tests__/useInfiniteQuery.test-d.tsx new file mode 100644 index 0000000000..a6a4b429e4 --- /dev/null +++ b/packages/react-query/src/__tests__/useInfiniteQuery.test-d.tsx @@ -0,0 +1,140 @@ +import { describe, expectTypeOf, it } from 'vitest' +import { QueryClient } from '@tanstack/query-core' +import { useInfiniteQuery } from '../useInfiniteQuery' +import { useQuery } from '../useQuery' +import type { InfiniteData } from '@tanstack/query-core' + +describe('pageParam', () => { + it('initialPageParam should define type of param passed to queryFunctionContext', () => { + useInfiniteQuery({ + queryKey: ['key'], + queryFn: ({ pageParam }) => { + expectTypeOf(pageParam).toEqualTypeOf() + }, + initialPageParam: 1, + getNextPageParam: () => undefined, + }) + }) + + it('direction should be passed to queryFn of useInfiniteQuery', () => { + useInfiniteQuery({ + queryKey: ['key'], + queryFn: ({ direction }) => { + expectTypeOf(direction).toEqualTypeOf<'forward' | 'backward'>() + }, + initialPageParam: 1, + getNextPageParam: () => undefined, + }) + }) + + it('there should be no pageParam passed to the queryFn of useQuery', () => { + useQuery({ + queryKey: ['key'], + // @ts-expect-error there should be no pageParam passed to queryFn of useQuery + queryFn: ({ pageParam }) => { + return String(pageParam) + }, + }) + }) + + it('there should be no direction passed to the queryFn of useQuery', () => { + useQuery({ + queryKey: ['key'], + // @ts-expect-error there should be no pageParam passed to queryFn of useQuery + queryFn: ({ direction }) => { + return String(direction) + }, + }) + }) + + it('initialPageParam should define type of param passed to queryFunctionContext for fetchInfiniteQuery', () => { + const queryClient = new QueryClient() + queryClient.fetchInfiniteQuery({ + queryKey: ['key'], + queryFn: ({ pageParam }) => { + expectTypeOf(pageParam).toEqualTypeOf() + }, + initialPageParam: 1, + }) + }) + + it('initialPageParam should define type of param passed to queryFunctionContext for prefetchInfiniteQuery', () => { + const queryClient = new QueryClient() + queryClient.prefetchInfiniteQuery({ + queryKey: ['key'], + queryFn: ({ pageParam }) => { + expectTypeOf(pageParam).toEqualTypeOf() + }, + initialPageParam: 1, + }) + }) +}) +describe('select', () => { + it('should still return paginated data if no select result', () => { + const infiniteQuery = useInfiniteQuery({ + queryKey: ['key'], + queryFn: ({ pageParam }) => { + return pageParam * 5 + }, + initialPageParam: 1, + getNextPageParam: () => undefined, + }) + + // TODO: Order of generics prevents pageParams to be typed correctly. Using `unknown` for now + expectTypeOf(infiniteQuery.data).toEqualTypeOf< + InfiniteData | undefined + >() + }) + + it('should be able to transform data to arbitrary result', () => { + const infiniteQuery = useInfiniteQuery({ + queryKey: ['key'], + queryFn: ({ pageParam }) => { + return pageParam * 5 + }, + initialPageParam: 1, + getNextPageParam: () => undefined, + select: (data) => { + expectTypeOf(data).toEqualTypeOf>() + return 'selected' as const + }, + }) + + expectTypeOf(infiniteQuery.data).toEqualTypeOf<'selected' | undefined>() + }) +}) +describe('getNextPageParam / getPreviousPageParam', () => { + it('should get typed params', () => { + const infiniteQuery = useInfiniteQuery({ + queryKey: ['key'], + queryFn: ({ pageParam }) => { + return String(pageParam) + }, + initialPageParam: 1, + getNextPageParam: (lastPage, allPages, lastPageParam, allPageParams) => { + expectTypeOf(lastPage).toEqualTypeOf() + expectTypeOf(allPages).toEqualTypeOf>() + expectTypeOf(lastPageParam).toEqualTypeOf() + expectTypeOf(allPageParams).toEqualTypeOf>() + return undefined + }, + getPreviousPageParam: ( + firstPage, + allPages, + firstPageParam, + allPageParams, + ) => { + expectTypeOf(firstPage).toEqualTypeOf() + expectTypeOf(allPages).toEqualTypeOf>() + expectTypeOf(firstPageParam).toEqualTypeOf() + expectTypeOf(allPageParams).toEqualTypeOf>() + return undefined + }, + }) + + // TODO: Order of generics prevents pageParams to be typed correctly. Using `unknown` for now + expectTypeOf(infiniteQuery.data).toEqualTypeOf< + InfiniteData | undefined + >() + }) +}) diff --git a/packages/react-query/src/__tests__/useInfiniteQuery.type.test.tsx b/packages/react-query/src/__tests__/useInfiniteQuery.type.test.tsx deleted file mode 100644 index 42e3ff27cc..0000000000 --- a/packages/react-query/src/__tests__/useInfiniteQuery.type.test.tsx +++ /dev/null @@ -1,224 +0,0 @@ -import { describe, it } from 'vitest' -import { QueryClient } from '@tanstack/query-core' -import { useInfiniteQuery } from '../useInfiniteQuery' -import { useQuery } from '../useQuery' -import { doNotExecute } from './utils' -import type { Equal, Expect } from './utils' -import type { InfiniteData } from '@tanstack/query-core' - -describe('pageParam', () => { - it('initialPageParam should define type of param passed to queryFunctionContext', () => { - doNotExecute(() => { - useInfiniteQuery({ - queryKey: ['key'], - queryFn: ({ pageParam }) => { - const result: Expect> = true - return result - }, - initialPageParam: 1, - getNextPageParam: () => undefined, - }) - }) - }) - - it('direction should be passed to queryFn of useInfiniteQuery', () => { - doNotExecute(() => { - useInfiniteQuery({ - queryKey: ['key'], - queryFn: ({ direction }) => { - const result: Expect< - Equal<'forward' | 'backward', typeof direction> - > = true - return result - }, - initialPageParam: 1, - getNextPageParam: () => undefined, - }) - }) - }) - - it('there should be no pageParam passed to the queryFn of useQuery', () => { - doNotExecute(() => { - useQuery({ - queryKey: ['key'], - // @ts-expect-error there should be no pageParam passed to queryFn of useQuery - queryFn: ({ pageParam }) => { - return String(pageParam) - }, - }) - }) - }) - - it('there should be no direction passed to the queryFn of useQuery', () => { - doNotExecute(() => { - useQuery({ - queryKey: ['key'], - // @ts-expect-error there should be no pageParam passed to queryFn of useQuery - queryFn: ({ direction }) => { - return String(direction) - }, - }) - }) - }) - - it('initialPageParam should define type of param passed to queryFunctionContext for fetchInfiniteQuery', () => { - doNotExecute(() => { - const queryClient = new QueryClient() - queryClient.fetchInfiniteQuery({ - queryKey: ['key'], - queryFn: ({ pageParam }) => { - const result: Expect> = true - return result - }, - initialPageParam: 1, - }) - }) - }) - - it('initialPageParam should define type of param passed to queryFunctionContext for prefetchInfiniteQuery', () => { - doNotExecute(() => { - const queryClient = new QueryClient() - queryClient.prefetchInfiniteQuery({ - queryKey: ['key'], - queryFn: ({ pageParam }) => { - const result: Expect> = true - return result - }, - initialPageParam: 1, - }) - }) - }) -}) -describe('select', () => { - it('should still return paginated data if no select result', () => { - doNotExecute(() => { - const infiniteQuery = useInfiniteQuery({ - queryKey: ['key'], - queryFn: ({ pageParam }) => { - return pageParam * 5 - }, - initialPageParam: 1, - getNextPageParam: () => undefined, - }) - - // TODO: Order of generics prevents pageParams to be typed correctly. Using `unknown` for now - const result: Expect< - Equal< - InfiniteData | undefined, - (typeof infiniteQuery)['data'] - > - > = true - - return result - }) - }) - - it('should be able to transform data to arbitrary result', () => { - doNotExecute(() => { - const infiniteQuery = useInfiniteQuery({ - queryKey: ['key'], - queryFn: ({ pageParam }) => { - return pageParam * 5 - }, - initialPageParam: 1, - getNextPageParam: () => undefined, - select: (data) => { - const result: Expect< - Equal, typeof data> - > = true - return result - }, - }) - - const result: Expect< - Equal - > = true - return result - }) - }) -}) -describe('getNextPageParam / getPreviousPageParam', () => { - it('should get typed params', () => { - doNotExecute(() => { - const infiniteQuery = useInfiniteQuery({ - queryKey: ['key'], - queryFn: ({ pageParam }) => { - return String(pageParam) - }, - initialPageParam: 1, - getNextPageParam: ( - lastPage, - allPages, - lastPageParam, - allPageParams, - ) => { - doNotExecute(() => { - const lastPageResult: Expect> = true - return lastPageResult - }) - doNotExecute(() => { - const allPagesResult: Expect< - Equal, typeof allPages> - > = true - return allPagesResult - }) - doNotExecute(() => { - const lastPageParamResult: Expect< - Equal - > = true - return lastPageParamResult - }) - doNotExecute(() => { - const allPageParamsResult: Expect< - Equal, typeof allPageParams> - > = true - return allPageParamsResult - }) - - return undefined - }, - getPreviousPageParam: ( - firstPage, - allPages, - firstPageParam, - allPageParams, - ) => { - doNotExecute(() => { - const firstPageResult: Expect> = - true - return firstPageResult - }) - doNotExecute(() => { - const allPagesResult: Expect< - Equal, typeof allPages> - > = true - return allPagesResult - }) - doNotExecute(() => { - const firstPageParamResult: Expect< - Equal - > = true - return firstPageParamResult - }) - doNotExecute(() => { - const allPageParamsResult: Expect< - Equal, typeof allPageParams> - > = true - return allPageParamsResult - }) - - return undefined - }, - }) - - // TODO: Order of generics prevents pageParams to be typed correctly. Using `unknown` for now - const result: Expect< - Equal< - InfiniteData | undefined, - (typeof infiniteQuery)['data'] - > - > = true - return result - }) - }) -}) diff --git a/packages/react-query/src/__tests__/useQueries.test-d.tsx b/packages/react-query/src/__tests__/useQueries.test-d.tsx new file mode 100644 index 0000000000..a1057201cc --- /dev/null +++ b/packages/react-query/src/__tests__/useQueries.test-d.tsx @@ -0,0 +1,126 @@ +import { describe, expectTypeOf, it } from 'vitest' +import { queryOptions } from '../queryOptions' +import { useQueries } from '../useQueries' +import type { UseQueryOptions } from '../types' + +describe('UseQueries config object overload', () => { + it('TData should always be defined when initialData is provided as an object', () => { + const query1 = { + queryKey: ['key1'], + queryFn: () => { + return { + wow: true, + } + }, + initialData: { + wow: false, + }, + } + + const query2 = { + queryKey: ['key2'], + queryFn: () => 'Query Data', + initialData: 'initial data', + } + + const query3 = { + queryKey: ['key2'], + queryFn: () => 'Query Data', + } + + const queryResults = useQueries({ queries: [query1, query2, query3] }) + + const query1Data = queryResults[0].data + const query2Data = queryResults[1].data + const query3Data = queryResults[2].data + + expectTypeOf(query1Data).toEqualTypeOf<{ wow: boolean }>() + expectTypeOf(query2Data).toEqualTypeOf() + expectTypeOf(query3Data).toEqualTypeOf() + }) + + it('TData should be defined when passed through queryOptions', () => { + const options = queryOptions({ + queryKey: ['key'], + queryFn: () => { + return { + wow: true, + } + }, + initialData: { + wow: true, + }, + }) + const queryResults = useQueries({ queries: [options] }) + + const data = queryResults[0].data + + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) + + it('it should be possible to define a different TData than TQueryFnData using select with queryOptions spread into useQuery', () => { + const query1 = queryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve(1), + select: (data) => data > 1, + }) + + const query2 = { + queryKey: ['key'], + queryFn: () => Promise.resolve(1), + select: (data: number) => data > 1, + } + + const queryResults = useQueries({ queries: [query1, query2] }) + const query1Data = queryResults[0].data + const query2Data = queryResults[1].data + + expectTypeOf(query1Data).toEqualTypeOf() + expectTypeOf(query2Data).toEqualTypeOf() + }) + + it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => { + const queryResults = useQueries({ + queries: [ + { + queryKey: ['key'], + queryFn: () => { + return { + wow: true, + } + }, + initialData: () => undefined as { wow: boolean } | undefined, + }, + ], + }) + + const data = queryResults[0].data + + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + }) + + describe('custom hook', () => { + it('should allow custom hooks using UseQueryOptions', () => { + type Data = string + + const useCustomQueries = ( + options?: Omit, 'queryKey' | 'queryFn'>, + ) => { + return useQueries({ + queries: [ + { + ...options, + queryKey: ['todos-key'], + queryFn: () => Promise.resolve('data'), + }, + ], + }) + } + + const queryResults = useCustomQueries() + const data = queryResults[0].data + + expectTypeOf(data).toEqualTypeOf() + }) + }) +}) diff --git a/packages/react-query/src/__tests__/useQueries.types.test.tsx b/packages/react-query/src/__tests__/useQueries.types.test.tsx deleted file mode 100644 index 6da3e2dd5e..0000000000 --- a/packages/react-query/src/__tests__/useQueries.types.test.tsx +++ /dev/null @@ -1,148 +0,0 @@ -import { describe, it } from 'vitest' -import { queryOptions, useQueries } from '..' -import { doNotExecute } from './utils' -import type { UseQueryOptions } from '..' -import type { Equal, Expect } from './utils' - -describe('UseQueries config object overload', () => { - it('TData should always be defined when initialData is provided as an object', () => { - const query1 = { - queryKey: ['key1'], - queryFn: () => { - return { - wow: true, - } - }, - initialData: { - wow: false, - }, - } - - const query2 = { - queryKey: ['key2'], - queryFn: () => 'Query Data', - initialData: 'initial data', - } - - const query3 = { - queryKey: ['key2'], - queryFn: () => 'Query Data', - } - - doNotExecute(() => { - const queryResults = useQueries({ queries: [query1, query2, query3] }) - - const query1Data = queryResults[0].data - const query2Data = queryResults[1].data - const query3Data = queryResults[2].data - - const result1: Expect> = true - - const result2: Expect> = true - - const result3: Expect> = true - - return result1 && result2 && result3 - }) - }) - - it('TData should be defined when passed through queryOptions', () => { - doNotExecute(() => { - const options = queryOptions({ - queryKey: ['key'], - queryFn: () => { - return { - wow: true, - } - }, - initialData: { - wow: true, - }, - }) - const queryResults = useQueries({ queries: [options] }) - - const data = queryResults[0].data - - const result: Expect> = true - return result - }) - }) - - it('it should be possible to define a different TData than TQueryFnData using select with queryOptions spread into useQuery', () => { - doNotExecute(() => { - const query1 = queryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve(1), - select: (data) => data > 1, - }) - - const query2 = { - queryKey: ['key'], - queryFn: () => Promise.resolve(1), - select: (data: number) => data > 1, - } - - const queryResults = useQueries({ queries: [query1, query2] }) - const query1Data = queryResults[0].data - const query2Data = queryResults[1].data - - const result1: Expect> = - true - const result2: Expect> = - true - return result1 && result2 - }) - }) - - it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => { - doNotExecute(() => { - const queryResults = useQueries({ - queries: [ - { - queryKey: ['key'], - queryFn: () => { - return { - wow: true, - } - }, - initialData: () => undefined as { wow: boolean } | undefined, - }, - ], - }) - - const data = queryResults[0].data - - const result: Expect> = - true - return result - }) - }) - - describe('custom hook', () => { - it('should allow custom hooks using UseQueryOptions', () => { - doNotExecute(() => { - type Data = string - - const useCustomQueries = ( - options?: Omit, 'queryKey' | 'queryFn'>, - ) => { - return useQueries({ - queries: [ - { - ...options, - queryKey: ['todos-key'], - queryFn: () => Promise.resolve('data'), - }, - ], - }) - } - - const queryResults = useCustomQueries() - const data = queryResults[0].data - - const result: Expect> = true - return result - }) - }) - }) -}) diff --git a/packages/react-query/src/__tests__/useQuery.test-d.tsx b/packages/react-query/src/__tests__/useQuery.test-d.tsx new file mode 100644 index 0000000000..286dfb89a2 --- /dev/null +++ b/packages/react-query/src/__tests__/useQuery.test-d.tsx @@ -0,0 +1,140 @@ +import { describe, expectTypeOf, it } from 'vitest' +import { useQuery } from '../useQuery' +import { queryOptions } from '../queryOptions' +import type { UseQueryOptions } from '../types' + +describe('initialData', () => { + describe('Config object overload', () => { + it('TData should always be defined when initialData is provided as an object', () => { + const { data } = useQuery({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, + }) + + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) + + it('TData should be defined when passed through queryOptions', () => { + const options = queryOptions({ + queryKey: ['key'], + queryFn: () => { + return { + wow: true, + } + }, + initialData: { + wow: true, + }, + }) + const { data } = useQuery(options) + + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) + + it('it should be possible to define a different TData than TQueryFnData using select with queryOptions spread into useQuery', () => { + const options = queryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve(1), + }) + + const query = useQuery({ + ...options, + select: (data) => data > 1, + }) + + expectTypeOf(query.data).toEqualTypeOf() + }) + + it('TData should always be defined when initialData is provided as a function which ALWAYS returns the data', () => { + const { data } = useQuery({ + queryKey: ['key'], + queryFn: () => { + return { + wow: true, + } + }, + initialData: () => ({ + wow: true, + }), + }) + + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) + + it('TData should have undefined in the union when initialData is NOT provided', () => { + const { data } = useQuery({ + queryKey: ['key'], + queryFn: () => { + return { + wow: true, + } + }, + }) + + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + }) + + it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => { + const { data } = useQuery({ + queryKey: ['key'], + queryFn: () => { + return { + wow: true, + } + }, + initialData: () => undefined as { wow: boolean } | undefined, + }) + + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + }) + + it('TData should be narrowed after an isSuccess check when initialData is provided as a function which can return undefined', () => { + const { data, isSuccess } = useQuery({ + queryKey: ['key'], + queryFn: () => { + return { + wow: true, + } + }, + initialData: () => undefined as { wow: boolean } | undefined, + }) + + if (isSuccess) { + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + } + }) + }) + + describe('custom hook', () => { + it('should allow custom hooks using UseQueryOptions', () => { + type Data = string + + const useCustomQuery = ( + options?: Omit, 'queryKey' | 'queryFn'>, + ) => { + return useQuery({ + ...options, + queryKey: ['todos-key'], + queryFn: () => Promise.resolve('data'), + }) + } + + const { data } = useCustomQuery() + + expectTypeOf(data).toEqualTypeOf() + }) + }) + + describe('structuralSharing', () => { + it('should restrict to same types', () => { + useQuery({ + queryKey: ['key'], + queryFn: () => 5, + structuralSharing: (_oldData, newData) => { + return newData + }, + }) + }) + }) +}) diff --git a/packages/react-query/src/__tests__/useQuery.types.test.tsx b/packages/react-query/src/__tests__/useQuery.types.test.tsx deleted file mode 100644 index 7717885bef..0000000000 --- a/packages/react-query/src/__tests__/useQuery.types.test.tsx +++ /dev/null @@ -1,179 +0,0 @@ -import { describe, it } from 'vitest' -import { useQuery } from '../useQuery' -import { queryOptions } from '../queryOptions' -import { doNotExecute } from './utils' -import type { UseQueryOptions } from '../types' -import type { Equal, Expect } from './utils' - -describe('initialData', () => { - describe('Config object overload', () => { - it('TData should always be defined when initialData is provided as an object', () => { - doNotExecute(() => { - const { data } = useQuery({ - queryKey: ['key'], - queryFn: () => { - return { - wow: true, - } - }, - initialData: { - wow: true, - }, - }) - - const result: Expect> = true - return result - }) - }) - - it('TData should be defined when passed through queryOptions', () => { - doNotExecute(() => { - const options = queryOptions({ - queryKey: ['key'], - queryFn: () => { - return { - wow: true, - } - }, - initialData: { - wow: true, - }, - }) - const { data } = useQuery(options) - - const result: Expect> = true - return result - }) - }) - - it('it should be possible to define a different TData than TQueryFnData using select with queryOptions spread into useQuery', () => { - doNotExecute(() => { - const options = queryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve(1), - }) - - const query = useQuery({ - ...options, - select: (data) => data > 1, - }) - - const result: Expect< - Equal - > = true - return result - }) - }) - - it('TData should always be defined when initialData is provided as a function which ALWAYS returns the data', () => { - doNotExecute(() => { - const { data } = useQuery({ - queryKey: ['key'], - queryFn: () => { - return { - wow: true, - } - }, - initialData: () => ({ - wow: true, - }), - }) - - const result: Expect> = true - return result - }) - }) - - it('TData should have undefined in the union when initialData is NOT provided', () => { - doNotExecute(() => { - const { data } = useQuery({ - queryKey: ['key'], - queryFn: () => { - return { - wow: true, - } - }, - }) - - const result: Expect> = - true - return result - }) - }) - - it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => { - doNotExecute(() => { - const { data } = useQuery({ - queryKey: ['key'], - queryFn: () => { - return { - wow: true, - } - }, - initialData: () => undefined as { wow: boolean } | undefined, - }) - - const result: Expect> = - true - return result - }) - }) - - it('TData should be narrowed after an isSuccess check when initialData is provided as a function which can return undefined', () => { - doNotExecute(() => { - const { data, isSuccess } = useQuery({ - queryKey: ['key'], - queryFn: () => { - return { - wow: true, - } - }, - initialData: () => undefined as { wow: boolean } | undefined, - }) - - if (isSuccess) { - const result: Expect> = true - return result - } - return false - }) - }) - }) - - describe('custom hook', () => { - it('should allow custom hooks using UseQueryOptions', () => { - doNotExecute(() => { - type Data = string - - const useCustomQuery = ( - options?: Omit, 'queryKey' | 'queryFn'>, - ) => { - return useQuery({ - ...options, - queryKey: ['todos-key'], - queryFn: () => Promise.resolve('data'), - }) - } - - const { data } = useCustomQuery() - - const result: Expect> = true - return result - }) - }) - }) - - describe('structuralSharing', () => { - it('should restrict to same types', () => { - doNotExecute(() => { - useQuery({ - queryKey: ['key'], - queryFn: () => 5, - structuralSharing: (_oldData, newData) => { - return newData - }, - }) - }) - }) - }) -}) diff --git a/packages/react-query/src/__tests__/utils.tsx b/packages/react-query/src/__tests__/utils.tsx index d99b53214f..6c0e79e2e8 100644 --- a/packages/react-query/src/__tests__/utils.tsx +++ b/packages/react-query/src/__tests__/utils.tsx @@ -78,14 +78,6 @@ export function setActTimeout(fn: () => void, ms?: number) { }, ms) } -export type Equal = (() => T extends TTargetA - ? 1 - : 2) extends () => T extends TTargetB ? 1 : 2 - ? true - : false - -export type Expect = T - /** * Assert the parameter is not typed as `any` */ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e79a5f6730..bc4efc2daa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24,7 +24,7 @@ importers: version: 0.4.4(@types/node@18.19.3)(esbuild@0.19.11)(rollup@4.6.0)(typescript@5.2.2)(vite@5.1.1) '@testing-library/jest-dom': specifier: ^6.4.2 - version: 6.4.2(vitest@1.2.2) + version: 6.4.2(vitest@1.3.1) '@testing-library/react': specifier: ^14.2.1 version: 14.2.1(react-dom@18.2.0)(react@18.2.0) @@ -47,8 +47,8 @@ importers: specifier: ^6.20.0 version: 6.20.0(eslint@8.56.0)(typescript@5.2.2) '@vitest/coverage-istanbul': - specifier: ^1.2.2 - version: 1.2.2(vitest@1.2.2) + specifier: ^1.3.1 + version: 1.3.1(vitest@1.3.1) cpy-cli: specifier: ^5.0.0 version: 5.0.0 @@ -116,8 +116,8 @@ importers: specifier: ^5.1.1 version: 5.1.1(@types/node@18.19.3) vitest: - specifier: ^1.2.2 - version: 1.2.2(@types/node@18.19.3)(jsdom@24.0.0) + specifier: ^1.3.1 + version: 1.3.1(@types/node@18.19.3)(jsdom@24.0.0) examples/angular/basic: dependencies: @@ -8995,7 +8995,7 @@ packages: pretty-format: 27.5.1 dev: true - /@testing-library/jest-dom@6.4.2(vitest@1.2.2): + /@testing-library/jest-dom@6.4.2(vitest@1.3.1): resolution: {integrity: sha512-CzqH0AFymEMG48CpzXFriYYkOjk6ZGPCLMhW9e9jg3KMCn5OfJecF8GtGW7yGfR/IgCe3SX8BSwjdzI6BBbZLw==} engines: {node: '>=14', npm: '>=6', yarn: '>=1'} peerDependencies: @@ -9024,7 +9024,7 @@ packages: dom-accessibility-api: 0.6.3 lodash: 4.17.21 redent: 3.0.0 - vitest: 1.2.2(@types/node@18.19.3)(jsdom@24.0.0) + vitest: 1.3.1(@types/node@18.19.3)(jsdom@24.0.0) /@testing-library/react@14.2.1(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-sGdjws32ai5TLerhvzThYFbpnF9XtL65Cjf+gB0Dhr29BGqK+mAeN7SURSdu+eqgET4ANcWoC7FQpkaiGvBr+A==} @@ -9948,10 +9948,10 @@ packages: vue: 3.3.0 dev: true - /@vitest/coverage-istanbul@1.2.2(vitest@1.2.2): - resolution: {integrity: sha512-tJybwO8JT4H9ANz0T0/tJ1M5g3BkuHKYF1w5YO3z9sAiHBdGANrxN9c5lomJx1WSnLzCxQR5xxlJ4TLKbzrR3w==} + /@vitest/coverage-istanbul@1.3.1(vitest@1.3.1): + resolution: {integrity: sha512-aBVgQ2eY9gzrxBJjGKbWgatTU2w1CacEx0n8OMctPzl9836KqoM5X/WigJpjM7wZEtX2N0ZTE5KDGPmVM+o2Wg==} peerDependencies: - vitest: ^1.0.0 + vitest: 1.3.1 dependencies: debug: 4.3.4(supports-color@6.1.0) istanbul-lib-coverage: 3.2.2 @@ -9962,39 +9962,39 @@ packages: magicast: 0.3.3 picocolors: 1.0.0 test-exclude: 6.0.0 - vitest: 1.2.2(@types/node@18.19.3)(jsdom@24.0.0) + vitest: 1.3.1(@types/node@18.19.3)(jsdom@24.0.0) transitivePeerDependencies: - supports-color dev: true - /@vitest/expect@1.2.2: - resolution: {integrity: sha512-3jpcdPAD7LwHUUiT2pZTj2U82I2Tcgg2oVPvKxhn6mDI2On6tfvPQTjAI4628GUGDZrCm4Zna9iQHm5cEexOAg==} + /@vitest/expect@1.3.1: + resolution: {integrity: sha512-xofQFwIzfdmLLlHa6ag0dPV8YsnKOCP1KdAeVVh34vSjN2dcUiXYCD9htu/9eM7t8Xln4v03U9HLxLpPlsXdZw==} dependencies: - '@vitest/spy': 1.2.2 - '@vitest/utils': 1.2.2 + '@vitest/spy': 1.3.1 + '@vitest/utils': 1.3.1 chai: 4.3.10 - /@vitest/runner@1.2.2: - resolution: {integrity: sha512-JctG7QZ4LSDXr5CsUweFgcpEvrcxOV1Gft7uHrvkQ+fsAVylmWQvnaAr/HDp3LAH1fztGMQZugIheTWjaGzYIg==} + /@vitest/runner@1.3.1: + resolution: {integrity: sha512-5FzF9c3jG/z5bgCnjr8j9LNq/9OxV2uEBAITOXfoe3rdZJTdO7jzThth7FXv/6b+kdY65tpRQB7WaKhNZwX+Kg==} dependencies: - '@vitest/utils': 1.2.2 + '@vitest/utils': 1.3.1 p-limit: 5.0.0 pathe: 1.1.2 - /@vitest/snapshot@1.2.2: - resolution: {integrity: sha512-SmGY4saEw1+bwE1th6S/cZmPxz/Q4JWsl7LvbQIky2tKE35US4gd0Mjzqfr84/4OD0tikGWaWdMja/nWL5NIPA==} + /@vitest/snapshot@1.3.1: + resolution: {integrity: sha512-EF++BZbt6RZmOlE3SuTPu/NfwBF6q4ABS37HHXzs2LUVPBLx2QoY/K0fKpRChSo8eLiuxcbCVfqKgx/dplCDuQ==} dependencies: magic-string: 0.30.5 pathe: 1.1.2 pretty-format: 29.7.0 - /@vitest/spy@1.2.2: - resolution: {integrity: sha512-k9Gcahssw8d7X3pSLq3e3XEu/0L78mUkCjivUqCQeXJm9clfXR/Td8+AP+VC1O6fKPIDLcHDTAmBOINVuv6+7g==} + /@vitest/spy@1.3.1: + resolution: {integrity: sha512-xAcW+S099ylC9VLU7eZfdT9myV67Nor9w9zhf0mGCYJSO+zM2839tOeROTdikOi/8Qeusffvxb/MyBSOja1Uig==} dependencies: tinyspy: 2.2.0 - /@vitest/utils@1.2.2: - resolution: {integrity: sha512-WKITBHLsBHlpjnDQahr+XK6RE7MiAsgrIkr0pGhQ9ygoxBfUeG0lUG5iLlzqjmKSlBv3+j5EGsriBzh+C3Tq9g==} + /@vitest/utils@1.3.1: + resolution: {integrity: sha512-d3Waie/299qqRyHTm2DjADeTaNdNSVsnwHPWrs20JMpjh6eiVq7ggggweO8rc4arhf6rRkWuHKwvxGvejUXZZQ==} dependencies: diff-sequences: 29.6.3 estree-walker: 3.0.3 @@ -19427,6 +19427,9 @@ packages: /js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + /js-tokens@8.0.3: + resolution: {integrity: sha512-UfJMcSJc+SEXEl9lH/VLHSZbThQyLpw1vLO1Lb+j4RWDvG3N2f7yj3PVQA3cmkTBNldJ9eFnM+xEXxHIXrYiJw==} + /js-yaml@3.14.1: resolution: {integrity: sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==} hasBin: true @@ -19965,6 +19968,8 @@ packages: peerDependenciesMeta: webpack: optional: true + webpack-sources: + optional: true dependencies: webpack: 5.89.0(esbuild@0.19.11) webpack-sources: 3.2.3 @@ -27276,6 +27281,12 @@ packages: resolution: {integrity: sha512-PugKzOsyXpArk0yWmUwqOZecSO0GH0bPoctLcqNDH9J04pVW3lflYE0ujElBGTloevcxF5MofAOZ7C5l2b+wLg==} dependencies: acorn: 8.11.3 + dev: false + + /strip-literal@2.0.0: + resolution: {integrity: sha512-f9vHgsCWBq2ugHAkGMiiYY+AYG0D/cbloKKg0nhaaaSNsujdGIpVXCNsrJpCKr5M0f4aI31mr13UjY6GAuXCKA==} + dependencies: + js-tokens: 8.0.3 /strnum@1.0.5: resolution: {integrity: sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==} @@ -29033,8 +29044,8 @@ packages: - xml2js dev: false - /vite-node@1.2.2(@types/node@18.19.3): - resolution: {integrity: sha512-1as4rDTgVWJO3n1uHmUYqq7nsFgINQ9u+mRcXpjeOMJUmviqNKjcZB7UfRZrlM7MjYXMKpuWp5oGkjaFLnjawg==} + /vite-node@1.3.1(@types/node@18.19.3): + resolution: {integrity: sha512-azbRrqRxlWTJEVbzInZCTchx0X69M/XPTCz4H+TLvlTcR/xH/3hkRqhOakT41fMJCMzXTu4UvegkZiEoJAWvng==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true dependencies: @@ -29144,7 +29155,7 @@ packages: optional: true dependencies: '@babel/core': 7.23.7 - '@testing-library/jest-dom': 6.4.2(vitest@1.2.2) + '@testing-library/jest-dom': 6.4.2(vitest@1.3.1) '@types/babel__core': 7.20.5 babel-preset-solid: 1.8.6(@babel/core@7.23.7) merge-anything: 5.1.7 @@ -29167,7 +29178,7 @@ packages: optional: true dependencies: '@babel/core': 7.23.7 - '@testing-library/jest-dom': 6.4.2(vitest@1.2.2) + '@testing-library/jest-dom': 6.4.2(vitest@1.3.1) '@types/babel__core': 7.20.5 babel-preset-solid: 1.8.6(@babel/core@7.23.7) merge-anything: 5.1.7 @@ -29309,15 +29320,15 @@ packages: dependencies: vite: 5.1.1(@types/node@18.19.3) - /vitest@1.2.2(@types/node@18.19.3)(jsdom@24.0.0): - resolution: {integrity: sha512-d5Ouvrnms3GD9USIK36KG8OZ5bEvKEkITFtnGv56HFaSlbItJuYr7hv2Lkn903+AvRAgSixiamozUVfORUekjw==} + /vitest@1.3.1(@types/node@18.19.3)(jsdom@24.0.0): + resolution: {integrity: sha512-/1QJqXs8YbCrfv/GPQ05wAZf2eakUPLPa18vkJAKE7RXOKfVHqMZZ1WlTjiwl6Gcn65M5vpNUB6EFLnEdRdEXQ==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: '@edge-runtime/vm': '*' '@types/node': ^18.0.0 || >=20.0.0 - '@vitest/browser': ^1.0.0 - '@vitest/ui': ^1.0.0 + '@vitest/browser': 1.3.1 + '@vitest/ui': 1.3.1 happy-dom: '*' jsdom: '*' peerDependenciesMeta: @@ -29335,13 +29346,12 @@ packages: optional: true dependencies: '@types/node': 18.19.3 - '@vitest/expect': 1.2.2 - '@vitest/runner': 1.2.2 - '@vitest/snapshot': 1.2.2 - '@vitest/spy': 1.2.2 - '@vitest/utils': 1.2.2 + '@vitest/expect': 1.3.1 + '@vitest/runner': 1.3.1 + '@vitest/snapshot': 1.3.1 + '@vitest/spy': 1.3.1 + '@vitest/utils': 1.3.1 acorn-walk: 8.3.2 - cac: 6.7.14 chai: 4.3.10 debug: 4.3.4(supports-color@6.1.0) execa: 8.0.1 @@ -29351,11 +29361,11 @@ packages: pathe: 1.1.2 picocolors: 1.0.0 std-env: 3.7.0 - strip-literal: 1.3.0 + strip-literal: 2.0.0 tinybench: 2.5.1 tinypool: 0.8.2 vite: 5.1.1(@types/node@18.19.3) - vite-node: 1.2.2(@types/node@18.19.3) + vite-node: 1.3.1(@types/node@18.19.3) why-is-node-running: 2.2.2 transitivePeerDependencies: - less