Skip to content

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

Open
lazerg wants to merge 1 commit into
TanStack:mainfrom
lazerg:fix/issue-11143-infinite-query-options-tdata
Open

fix({react,preact}-query): default 'TData' of infinite query options to 'InfiniteData'#11147
lazerg wants to merge 1 commit into
TanStack:mainfrom
lazerg:fix/issue-11143-infinite-query-options-tdata

Conversation

@lazerg

@lazerg lazerg commented Aug 6, 2026

Copy link
Copy Markdown

🎯 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 to verify correct inferred types for infinite-query results and suspense infinite-query results in both integrations.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes update both infinite-query option defaults, include suspense variants, and align React and Preact types with InfiniteData as required by #11143.
Out of Scope Changes check ✅ Passed The changes are limited to the requested React and Preact type updates, focused type tests, and the required changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely describes the main change to default TData for React and Preact infinite-query options.
Description check ✅ Passed The description includes the change, motivation, scope, issue reference, completed checklist items, and changeset release impact.
✨ 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
lazerg force-pushed the fix/issue-11143-infinite-query-options-tdata branch from 20a9657 to 0f4fd04 Compare August 7, 2026 00:05
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

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.

Sign up for free to 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

1 participant