TanStack / query

🤖 Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query.
https://tanstack.com/query
MIT License
42.72k stars 2.93k forks source link

fix(react-query): Allow optional initialData in infiniteQueryOptions #8154

Closed sungpaks closed 1 month ago

sungpaks commented 1 month ago

Issue fix : #8132
There was a typescript error(but could be run with no problem) when using optional initialData in infiniteQueryOptions

nx-cloud[bot] commented 1 month ago

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 45db43366dd20cba2a73df2153fa0c54d4036905. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets - [`nx affected --targets=test:sherif,test:knip,test:eslint,test:lib,test:types,test:build,build --parallel=3`](https://cloud.nx.app/runs/5Fu8JI0f0d?utm_source=pull-request&utm_medium=comment) - [`nx run-many --target=build --exclude=examples/** --exclude=integrations/**`](https://cloud.nx.app/runs/2dnJTGujY3?utm_source=pull-request&utm_medium=comment)

Sent with 💌 from NxCloud.

pkg-pr-new[bot] commented 1 month ago

Open in Stackblitz

More templates

- [@tanstack/query-example-angular-basic](https://pkg.pr.new/template/6629d313-f021-46b7-bd7f-5f25e3ef5e65) - [@tanstack/query-example-angular-infinite-query-with-max-pages](https://pkg.pr.new/template/049dd3da-d141-4f38-8141-20459772c69e) - [@tanstack/query-example-angular-pagination](https://pkg.pr.new/template/ed3a44cb-cf45-4d02-b596-d81f36cdca12) - [@tanstack/query-example-angular-router](https://pkg.pr.new/template/50921252-8a95-42a2-9ff4-c4ab4feabdfc) - [@tanstack/query-example-angular-rxjs](https://pkg.pr.new/template/28099348-df92-425b-8aef-d83964e3168b) - [@tanstack/query-example-angular-simple](https://pkg.pr.new/template/d8fbd114-68da-426e-aeae-fc24752f2d04) - [@tanstack/query-example-react-algolia](https://pkg.pr.new/template/176451ca-68f7-4406-a593-8b58ada74093) - [@tanstack/query-example-react-auto-refetching](https://pkg.pr.new/template/6383dd5b-17e5-4d9f-b32f-509d7ac709c3) - [@tanstack/query-example-react-basic](https://pkg.pr.new/template/1f368c98-65c2-4854-ab45-10c3f9dda7d3) - [@tanstack/query-example-react-basic-graphql-request](https://pkg.pr.new/template/27d78905-fbfd-4e09-a73f-710fddc6f035) - [@tanstack/query-example-react-default-query-function](https://pkg.pr.new/template/fce2cbbc-0bcb-4d1d-8317-c22aa9e8d515) - [@tanstack/query-example-react-devtools-panel](https://pkg.pr.new/template/0c981fb4-76c9-4149-ad8a-5383f0e95e86) - [@tanstack/query-example-react-infinite-query-with-max-pages](https://pkg.pr.new/template/c03adf58-fc65-4fe3-aad6-971a0839fc5b) - [@tanstack/query-example-react-load-more-infinite-scroll](https://pkg.pr.new/template/4c99263b-c161-4ce7-8496-7c5f5ee8d218) - [@tanstack/query-example-react-nextjs](https://pkg.pr.new/template/fcc7f8b1-95f5-43aa-b0ca-017130ea43cd) - [@tanstack/query-example-react-nextjs-app-prefetching](https://pkg.pr.new/template/2c6489db-47d4-472c-9cd7-bc9db76909f6) - [@tanstack/query-example-nextjs-suspense-streaming](https://pkg.pr.new/template/33d56e5e-14b0-47a4-9268-25c9dbb6e511) - [@tanstack/query-example-react-offline](https://pkg.pr.new/template/5696d9a9-2690-4aa9-ab0f-e105f19b5855) - [@tanstack/query-example-react-optimistic-updates-cache](https://pkg.pr.new/template/28d9ee33-3305-4dbe-85dc-f834bd89d9d7) - [@tanstack/query-example-react-optimistic-updates-ui](https://pkg.pr.new/template/8e74cb1f-89f8-4ca1-a152-4806a6bc764a) - [@tanstack/query-example-react-pagination](https://pkg.pr.new/template/5c12a736-1c34-405d-9c6e-48faf7230dce) - [@tanstack/query-example-react-playground](https://pkg.pr.new/template/63d90eb8-f155-4388-877b-558447dd4356) - [@tanstack/query-example-react-prefetching](https://pkg.pr.new/template/b6056574-e0dd-4565-96c7-04270c5ac6a9) - [@tanstack/query-example-react-react-native](https://pkg.pr.new/template/d8efb48a-9c8f-4611-9abb-394e15468e43) - [@tanstack/query-example-react-router](https://pkg.pr.new/template/780c64df-1525-4ea8-a12b-b31369bbac0c) - [@tanstack/query-example-react-rick-morty](https://pkg.pr.new/template/bd890106-5453-4843-b451-c488a9656f4d) - [@tanstack/query-example-react-shadow-dom](https://pkg.pr.new/template/d9f09573-cc0c-46d7-803b-1331926e63b6) - [@tanstack/query-example-react-simple](https://pkg.pr.new/template/8956926a-5719-4804-adcf-6b4a10390b2d) - [@tanstack/query-example-react-star-wars](https://pkg.pr.new/template/278c8681-9c44-452a-948e-cb77be8c32a7) - [@tanstack/query-example-react-suspense](https://pkg.pr.new/template/a564ec0f-0178-4943-a02c-4a65586b1bb0) - [@tanstack/query-example-svelte-auto-refetching](https://pkg.pr.new/template/b66ffd91-2db0-41a2-a23b-4a16583058d3) - [@tanstack/query-example-svelte-basic](https://pkg.pr.new/template/d476f31d-ddb1-49f9-afaf-76fb4399161a) - [@tanstack/query-example-svelte-load-more-infinite-scroll](https://pkg.pr.new/template/55605175-e7ea-4e95-8e44-c99633929746) - [@tanstack/query-example-svelte-optimistic-updates](https://pkg.pr.new/template/afc2c30c-1036-4088-bcd6-d2bc83651768) - [@tanstack/query-example-svelte-playground](https://pkg.pr.new/template/b7eab1d2-a309-4b16-a601-b3fc4aafec6b) - [@tanstack/query-example-svelte-simple](https://pkg.pr.new/template/1a288a14-a32e-466a-86e8-4383c1277d5d) - [@tanstack/query-example-svelte-ssr](https://pkg.pr.new/template/130302a3-e48d-4ee5-bf11-4d49bb387462) - [@tanstack/query-example-svelte-star-wars](https://pkg.pr.new/template/48ca9fed-ee85-4bb6-92fb-029d7e2a5a7e) - [@tanstack/query-example-solid-astro](https://pkg.pr.new/template/9ff49b60-c0b8-436e-8d14-4b1bbee48166) - [@tanstack/query-example-solid-basic](https://pkg.pr.new/template/b2fa797b-42ce-454c-acde-c3077c718dea) - [@tanstack/query-example-solid-basic-graphql-request](https://pkg.pr.new/template/af79647c-c246-41d4-b48d-57a96c829e95) - [@tanstack/query-example-solid-default-query-function](https://pkg.pr.new/template/d1cce186-cd6d-487e-b089-485f1d1e07c4) - [@tanstack/query-example-solid-simple](https://pkg.pr.new/template/9ccf27ff-6cae-4b0a-b9e1-e980b9803236) - [@tanstack/query-example-solid-start-streaming](https://pkg.pr.new/template/4f1604dd-018f-4c26-b921-2ae8992933cf) - [@tanstack/query-example-vue-2.6-basic](https://pkg.pr.new/template/45bd4e3e-b41e-4080-a1de-33de53510a92) - [@tanstack/query-example-vue-2.7-basic](https://pkg.pr.new/template/f2fdd836-760b-47cf-a92e-ddde90d057cd) - [@tanstack/query-example-vue-basic](https://pkg.pr.new/template/cbbd80f6-16f7-4a08-bd51-3ec0a38e27ca) - [@tanstack/query-example-vue-dependent-queries](https://pkg.pr.new/template/68a23eb2-8bfc-4f89-82fe-4245604c897e) - [@tanstack/query-example-vue-nuxt3](https://pkg.pr.new/template/4b7ebdb0-7edc-4706-9d9f-c2c616889c51) - [@tanstack/query-example-vue-persister](https://pkg.pr.new/template/a5cf9120-a6d1-4121-a24d-1f4037a30a68) - [@tanstack/query-example-vue-simple](https://pkg.pr.new/template/ef863cca-e9ed-47cd-834f-85e9631fd71e)

@tanstack/angular-query-devtools-experimental

``` pnpm add https://pkg.pr.new/@tanstack/angular-query-devtools-experimental@8154 ```

@tanstack/eslint-plugin-query

``` pnpm add https://pkg.pr.new/@tanstack/eslint-plugin-query@8154 ```

@tanstack/angular-query-experimental

``` pnpm add https://pkg.pr.new/@tanstack/angular-query-experimental@8154 ```

@tanstack/query-async-storage-persister

``` pnpm add https://pkg.pr.new/@tanstack/query-async-storage-persister@8154 ```

@tanstack/query-broadcast-client-experimental

``` pnpm add https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@8154 ```

@tanstack/query-core

``` pnpm add https://pkg.pr.new/@tanstack/query-core@8154 ```

@tanstack/query-devtools

``` pnpm add https://pkg.pr.new/@tanstack/query-devtools@8154 ```

@tanstack/query-persist-client-core

``` pnpm add https://pkg.pr.new/@tanstack/query-persist-client-core@8154 ```

@tanstack/query-sync-storage-persister

``` pnpm add https://pkg.pr.new/@tanstack/query-sync-storage-persister@8154 ```

@tanstack/react-query-devtools

``` pnpm add https://pkg.pr.new/@tanstack/react-query-devtools@8154 ```

@tanstack/react-query

``` pnpm add https://pkg.pr.new/@tanstack/react-query@8154 ```

@tanstack/react-query-next-experimental

``` pnpm add https://pkg.pr.new/@tanstack/react-query-next-experimental@8154 ```

@tanstack/react-query-persist-client

``` pnpm add https://pkg.pr.new/@tanstack/react-query-persist-client@8154 ```

@tanstack/solid-query

``` pnpm add https://pkg.pr.new/@tanstack/solid-query@8154 ```

@tanstack/solid-query-devtools

``` pnpm add https://pkg.pr.new/@tanstack/solid-query-devtools@8154 ```

@tanstack/solid-query-persist-client

``` pnpm add https://pkg.pr.new/@tanstack/solid-query-persist-client@8154 ```

@tanstack/svelte-query-devtools

``` pnpm add https://pkg.pr.new/@tanstack/svelte-query-devtools@8154 ```

@tanstack/svelte-query

``` pnpm add https://pkg.pr.new/@tanstack/svelte-query@8154 ```

@tanstack/svelte-query-persist-client

``` pnpm add https://pkg.pr.new/@tanstack/svelte-query-persist-client@8154 ```

@tanstack/vue-query

``` pnpm add https://pkg.pr.new/@tanstack/vue-query@8154 ```

@tanstack/vue-query-devtools

``` pnpm add https://pkg.pr.new/@tanstack/vue-query-devtools@8154 ```

commit: 45db433

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 81.89%. Comparing base (2fe16e5) to head (45db433). Report is 12 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/TanStack/query/pull/8154/graphs/tree.svg?width=650&height=150&src=pr&token=jqEbswkEDQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack)](https://app.codecov.io/gh/TanStack/query/pull/8154?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) ```diff @@ Coverage Diff @@ ## main #8154 +/- ## =========================================== + Coverage 45.41% 81.89% +36.48% =========================================== Files 200 26 -174 Lines 7456 359 -7097 Branches 1696 99 -1597 =========================================== - Hits 3386 294 -3092 + Misses 3694 56 -3638 + Partials 376 9 -367 ``` | [Components](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | Coverage Δ | | |---|---|---| | [@tanstack/angular-query-devtools-experimental](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/angular-query-experimental](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/eslint-plugin-query](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/query-async-storage-persister](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/query-broadcast-client-experimental](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/query-codemods](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/query-core](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/query-devtools](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/query-persist-client-core](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/query-sync-storage-persister](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/react-query](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `93.12% <100.00%> (ø)` | | | [@tanstack/react-query-devtools](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `10.00% <ø> (ø)` | | | [@tanstack/react-query-next-experimental](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/react-query-persist-client](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `100.00% <ø> (ø)` | | | [@tanstack/solid-query](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/solid-query-devtools](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/solid-query-persist-client](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/svelte-query](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/svelte-query-devtools](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/svelte-query-persist-client](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/vue-query](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | | | [@tanstack/vue-query-devtools](https://app.codecov.io/gh/TanStack/query/pull/8154/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | |
sungpaks commented 1 month ago

can you please add a type test to packages/react-query/src/__tests__/infiniteQueryOptions.test-d.tsx that fails before and succeeds with your fix ?

I added a type test that failed before and succeeds with my fix.

jimmycallin commented 1 month ago

thanks for addressing my issue so quickly! i added a post-merge comment with a potential overlook. :)