Skip to content

fix(vue-query): export queryOptions declaration types#11098

Open
ousamabenyounes wants to merge 3 commits into
TanStack:mainfrom
ousamabenyounes:fix/issue-11042
Open

fix(vue-query): export queryOptions declaration types#11098
ousamabenyounes wants to merge 3 commits into
TanStack:mainfrom
ousamabenyounes:fix/issue-11042

Conversation

@ousamabenyounes

@ousamabenyounes ousamabenyounes commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

🎯 Changes

  • Export reusable queryOptions declaration types from Vue Query.
  • Expose the matching Query Core declaration types needed by the Vue exports.
  • Preserve direct, ref, computed, and getter queryKey shapes while retaining DataTag metadata.
  • Keep the previous useQuery initial-data helper types available as UndefinedInitialUseQueryOptions and DefinedInitialUseQueryOptions.

Fixes #11042

✅ Checklist

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

Targeted local verification:

  • pnpm exec nx run @tanstack/vue-query:test:types --skip-nx-cache
  • pnpm exec nx run @tanstack/vue-query:build --skip-nx-cache

🚀 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

  • New Features
    • Expanded the public TypeScript API for Vue Query and core packages, including additional query behavior, retry configuration, and query options helper types.
    • Improved queryOptions TypeScript inference for queryKey and better select narrowing—especially for portable queryOptions factory patterns.
  • Tests
    • Strengthened type-level tests and added declaration-emit checks to ensure correct compile-time behavior.
  • Release
    • Published patch releases for core and Vue Query packages.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

queryOptions now uses an exported QueryOptionsDataTag type, related Vue Query and Query Core types are publicly re-exported, and declaration-emit compatibility is covered by TypeScript tests.

Changes

Vue Query options type surface

Layer / File(s) Summary
Tagged queryOptions return types
packages/vue-query/src/queryOptions.ts
Adds QueryOptionsDataTag, derives tagged queryKey shapes for supported Vue forms, and applies it to defined and undefined queryOptions overloads.
Public supporting type exports
packages/vue-query/src/index.ts, packages/query-core/src/index.ts, .changeset/calm-vue-query-options.md
Re-exports Vue Query option types, supporting Vue types, and Query Core types, and records patch releases.
Declaration-emit type validation
packages/vue-query/src/__tests__/queryOptions.test-d.ts
Verifies exact tagged queryKey inference and public queryOptions factory usage, including select callback typing.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested labels: package: vue-query, package: query-core

Suggested reviewers: tkdodo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes export the new queryOptions declaration types, required query-core types, and add type coverage for DataTag/select behavior.
Out of Scope Changes check ✅ Passed The changes stay focused on vue-query/query-core type exports, declaration tests, and a changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title matches the main change: exporting reusable Vue Query declaration types.
Description check ✅ Passed The description covers changes, verification, and release impact, but it omits the checklist items from the template.
✨ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/vue-query/src/queryOptions.ts`:
- Around line 68-71: Update QueryOptionsDataTag so its queryKey property
preserves the reactive MaybeRefOrGetter<TQueryKey> shape while retaining the
DataTag<TQueryKey, TQueryFnData, TError> metadata. Keep the existing omission
and tagging behavior unchanged, ensuring refs and getters remain valid in the
returned options type.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 668e95eb-d1d5-4dcf-8b09-09a6b78764aa

📥 Commits

Reviewing files that changed from the base of the PR and between 86bb8a6 and d29124e.

📒 Files selected for processing (5)
  • .changeset/calm-vue-query-options.md
  • packages/query-core/src/index.ts
  • packages/vue-query/src/__tests__/queryOptions.test-d.ts
  • packages/vue-query/src/index.ts
  • packages/vue-query/src/queryOptions.ts

Comment thread packages/vue-query/src/queryOptions.ts
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.

vue-query: queryOptions()'s real return type is unexported; the public name with the same identifier points at a different, legacy type

1 participant