Skip to content

fix(lit-query): brand infiniteQueryOptions queryKey with DataTag - #11167

Open
vedantchalke36 wants to merge 1 commit into
TanStack:mainfrom
vedantchalke36:fix/lit-query-infinite-query-options-datatag
Open

fix(lit-query): brand infiniteQueryOptions queryKey with DataTag#11167
vedantchalke36 wants to merge 1 commit into
TanStack:mainfrom
vedantchalke36:fix/lit-query-infinite-query-options-datatag

Conversation

@vedantchalke36

@vedantchalke36 vedantchalke36 commented Aug 11, 2026

Copy link
Copy Markdown

Fix [lit-query] infiniteQueryOptions missing DataTag on queryKey (#11142).

Problem

infiniteQueryOptions was the only *QueryOptions helper not branding its queryKey with DataTag. As a result, queryClient.setQueryData(infiniteQuerySlugType, ...) / getQueryData could not infer the InfiniteData type from a tagged key — the updater's old data fell back to unknown, and caching through a shared options object lost its type safety.

queryOptions already brands the key (with type tests), and react-query, vue-query and solid-query all brand it in their infiniteQueryOptions — lit-query was the outlier.

Changes

  • packages/lit-query/src/infiniteQueryOptions.ts: return type now intersects { queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError> } — same shape as react-query/vue-query.
  • packages/lit-query/src/tests/type-inference.test.ts: regression tests mirroring the existing queryOptions checks — queryKey[dataTagSymbol] is InfiniteData<{ page: number }>, and getQueryData/setQueryData infer the tagged data (the exact scenario from the issue).
  • .changeset/quiet-mice-invent.md: patch for @tanstack/lit-query.

Test

The lit-query test:lib suite (type-inference tests run under vitest + tsc) is exercised by CI on this PR; could not run locally without installing the monorepo.

Closes #11142

Summary by CodeRabbit

  • Bug Fixes

    • Improved type inference for infinite query options.
    • getQueryData and setQueryData now correctly infer infinite query data types from associated query keys.
  • Tests

    • Added coverage for inferred infinite-query data, cached data, and update results.

infiniteQueryOptions was the only helper not tagging its queryKey, so
setQueryData/getQueryData could not infer the InfiniteData type from a
tagged query key. Add the same DataTag enrichment queryOptions and the
other adapters (react-query, vue-query, solid-query) already ship.

Closes TanStack#11142
@coderabbitai

coderabbitai Bot commented Aug 11, 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: 04544ae9-0829-4b90-923b-14081bbf6061

📥 Commits

Reviewing files that changed from the base of the PR and between 46d7f02 and 4eeb47d.

📒 Files selected for processing (3)
  • .changeset/quiet-mice-invent.md
  • packages/lit-query/src/infiniteQueryOptions.ts
  • packages/lit-query/src/tests/type-inference.test.ts

📝 Walkthrough

Walkthrough

The PR brands infiniteQueryOptions query keys with DataTag and InfiniteData. Type-inference tests verify getQueryData and setQueryData receive the inferred infinite-query types. A patch changeset documents the update.

Changes

lit-query infinite query key branding

Layer / File(s) Summary
Infinite query key type contract
packages/lit-query/src/infiniteQueryOptions.ts
infiniteQueryOptions now returns a queryKey branded with DataTag, InfiniteData<TQueryFnData>, and TError.
Inference validation and release metadata
packages/lit-query/src/tests/type-inference.test.ts, .changeset/quiet-mice-invent.md
Type tests verify InfiniteData inference through getQueryData and setQueryData. The changeset records a patch release.

|

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

Possibly related PRs

  • TanStack/query#11146: Makes the same infiniteQueryOptions DataTag change and adds related lit-query type tests.
  • TanStack/query#11164: Changes TypeScript inference for infinite queries in a different package and through NoInfer.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change to brand lit-query infiniteQueryOptions query keys with DataTag.
Description check ✅ Passed The description explains the problem, implementation, tests, release impact, and linked issue, although it does not use every template heading.
Linked Issues check ✅ Passed The implementation and regression tests address issue #11142 by adding DataTag branding and restoring InfiniteData inference for getQueryData and setQueryData.
Out of Scope Changes check ✅ Passed The changeset, implementation update, and type-inference tests are directly related to the linked issue and stated pull request objectives.
Docstring Coverage ✅ Passed No 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.

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.

[lit-query] infiniteQueryOptions does not have DataTag on queryKey

1 participant