Skip to content

fix({react,preact}-query): default 'TData' of infinite query options to 'InfiniteData' - #11147

Merged
TkDodo merged 2 commits into
TanStack:mainfrom
lazerg:fix/issue-11143-infinite-query-options-tdata
Aug 18, 2026
Merged

fix({react,preact}-query): default 'TData' of infinite query options to 'InfiniteData'#11147
TkDodo merged 2 commits into
TanStack:mainfrom
lazerg:fix/issue-11143-infinite-query-options-tdata

Conversation

@lazerg

@lazerglazerg commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

🎯 Changes

UseInfiniteQueryOptions defaults TData to TQueryFnData, but useInfiniteQuery defaults it to InfiniteData<TQueryFnData>. Passing an options object typed with the defaults into the hook therefore resolves data to a single page instead of the paginated shape, and every wrapper has to spell out the generics by hand.

Both defaults now agree. Same change for UseSuspenseInfiniteQueryOptions, and for the preact-query copies of these types.

The same mismatch exists in vue-query, solid-query, svelte-query and angular-query-experimental, and one layer down in query-core's InfiniteQueryObserverOptions. I left those out to keep this scoped to the reported case, but happy to follow up if you want them aligned too.

Fixes#11143

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes

    • Improved TypeScript inference for infinite queries and suspense infinite queries.
    • Query option types now correctly default returned data to the complete infinite-data structure in React and Preact integrations.
    • This provides more accurate type checking and editor suggestions when configuring or consuming infinite-query results.
  • Tests

    • Added coverage verifying inferred types for infinite-query and suspense infinite-query results in both integrations.

@coderabbitai

coderabbitaiBot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b3e594df-6663-4880-b4af-a11efbc2b561

📥 Commits

Reviewing files that changed from the base of the PR and between 18c1c1e and 877090f.

📒 Files selected for processing (7)
  • .changeset/gentle-moons-shave.md
  • packages/preact-query/src/__tests__/useInfiniteQuery.test-d.tsx
  • packages/preact-query/src/__tests__/useSuspenseInfiniteQuery.test-d.tsx
  • packages/preact-query/src/types.ts
  • packages/react-query/src/__tests__/useInfiniteQuery.test-d.tsx
  • packages/react-query/src/__tests__/useSuspenseInfiniteQuery.test-d.tsx
  • packages/react-query/src/types.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • packages/preact-query/src/tests/useInfiniteQuery.test-d.tsx
  • .changeset/gentle-moons-shave.md
  • packages/react-query/src/tests/useInfiniteQuery.test-d.tsx
  • packages/react-query/src/tests/useSuspenseInfiniteQuery.test-d.tsx
  • packages/preact-query/src/types.ts
  • packages/preact-query/src/tests/useSuspenseInfiniteQuery.test-d.tsx
  • packages/react-query/src/types.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The React and Preact infinite-query option types now default TData to InfiniteData<TQueryFnData>. Type tests verify regular and suspense hooks. A patch changeset documents the update for both packages.

Changes

Infinite query type defaults

Layer / File(s)Summary
Update infinite-query option defaults
packages/react-query/src/types.ts, packages/preact-query/src/types.ts
The UseInfiniteQueryOptions and UseSuspenseInfiniteQueryOptions defaults now use InfiniteData<TQueryFnData>.
Validate adapter type inference
packages/react-query/src/__tests__/*, packages/preact-query/src/__tests__/*, .changeset/gentle-moons-shave.md
Type tests verify the inferred data types for regular and suspense infinite queries. The changeset documents the patch release.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk:⚪ Minimal · up to 87709

This narrowly scoped change aligns infinite-query option defaults with the paginated data returned by the hooks; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Title check✅ PassedThe title clearly identifies the React and Preact Query type fix and the corrected default for infinite-query options.
Description check✅ PassedThe description explains the bug, scope, tests, changeset, and linked issue, and it completes the required template sections.
Linked Issues check✅ PassedThe changes implement the linked issue by correcting both infinite-query option defaults, including suspense variants, with supporting type tests.
Out of Scope Changes check✅ PassedThe changes remain within the stated React Query and Preact Query scope and do not modify excluded adapters or query-core.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lazerg
lazergforce-pushed the fix/issue-11143-infinite-query-options-tdata branch from 20a9657 to 0f4fd04CompareAugust 7, 2026 00:05
@coderabbitai

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@nx-cloud

nx-cloudBot commented Aug 18, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 877090f

CommandStatusDurationResult
nx run-many --target=build --exclude=examples/*...✅ Succeeded1m 48sView ↗
nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded4m 1sView ↗

☁️ Nx Cloud last updated this comment at 2026-08-18 08:46:48 UTC

@pkg-pr-new

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@11147

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@11147

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@11147

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@11147

@tanstack/preact-query-devtools

npm i https://pkg.pr.new/@tanstack/preact-query-devtools@11147

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@11147

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@11147

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@11147

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@11147

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@11147

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@11147

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@11147

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@11147

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@11147

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@11147

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@11147

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@11147

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@11147

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@11147

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@11147

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@11147

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@11147

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@11147

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@11147

commit: 877090f

@TkDodo
TkDodo merged commit cb6c9d3 into TanStack:mainAug 18, 2026
9 checks passed
@github-actionsgithub-actionsBot mentioned this pull request Aug 18, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong default for TData in UseInfiniteQueryOptions

2 participants

@lazerg@TkDodo