Skip to content

fix(vue-query,query-core): export queryOptions supporting types and add declaration-emit tests - #12723

Open
2tsoftwareapp wants to merge 1 commit into
TanStack:mainfrom
2tsoftwareapp:bugfix/vue-query/query-options-return-types
Open

2tsoftwareapp wants to merge 1 commit into
TanStack:mainfrom
2tsoftwareapp:bugfix/vue-query/query-options-return-types

Conversation

@2tsoftwareapp

@2tsoftwareapp 2tsoftwareapp commented Nov 30, 2026 •

Copy link
Copy Markdown

Changes

Follow-up for #11042 (after #11224 resolved the duplicate UndefinedInitialQueryOptions / DefinedInitialQueryOptions export collision):

  • Export supporting types referenced by queryOptions / QueryOptions / UseQueryOptions signatures so TypeScript does not hit TS2883 when expanding option types under declaration emit:
    • @tanstack/query-core: QueryBehavior, RetryValue, RetryDelayValue, FetchContext, FetchDirection, FetchMeta, FetchOptions
    • @tanstack/vue-query: ShallowOption, MaybeRefOrGetter, MaybeRef, MaybeRefDeep, MaybeGetter, DeepUnwrapRef
  • Add declaration-emit and consumer-spread regression tests in packages/vue-query/src/__tests__/queryOptions.test-d.ts and integrations/vue/declaration-emit/ verifying exported factory functions, spreading into queryOptions({ ...opts, select }), select inference, and DataTag preservation in queryClient.getQueryData(queryKey).
  • Add a patch changeset for @tanstack/query-core and @tanstack/vue-query.

Verification

  • pnpm oxfmt --check on all changed files
  • pnpm run test:knip && pnpm run test:sherif && pnpm run test:docs
  • pnpm nx run-many --targets=build,test:build,test:oxlint,test:eslint,test:types,test:lib --projects=@tanstack/query-core,@tanstack/vue-query (TS 5.7–7.1, Vue 2 / 2.7 / 3, publint + attw)
  • pnpm nx run @tanstack/query-integration-vue-declaration-emit:test:types (TS 6.0 / 7.0 / 7.1 with skipLibCheck: false)

Checklist

  • I have read the Contributing Guide and AI Policy.
  • Verified locally with package build, lint, typecheck, unit tests, and declaration-emit integration tests.
  • Added a changeset for @tanstack/query-core and @tanstack/vue-query.

Summary by CodeRabbit

  • New Features
    • Added public TypeScript exports for query-core and Vue Query supporting types, including retry, fetch, and Vue reactivity types.
    • Improved type support for Vue Query options, including selected results, options with defined or undefined initial data, and options created through factories. These types are also preserved when retrieving cached query data.
    • Added support for query option IDs supplied as values, refs, or getters, including IDs that may be undefined.
@changeset-bot

changeset-bot Bot commented Nov 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a491bb7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 26 packages
Name Type
@tanstack/query-core Patch
@tanstack/vue-query Patch
@tanstack/angular-query Patch
@tanstack/lit-query Patch
@tanstack/preact-query Patch
@tanstack/query-async-storage-persister Patch
@tanstack/query-broadcast-client-experimental Patch
@tanstack/query-devtools Patch
@tanstack/query-persist-client-core Patch
@tanstack/query-sync-storage-persister Patch
@tanstack/react-query Patch
@tanstack/solid-query Patch
@tanstack/svelte-query Patch
@tanstack/vue-query-devtools Patch
@tanstack/angular-query-devtools Patch
@tanstack/angular-query-persist-client Patch
@tanstack/preact-query-devtools Patch
@tanstack/preact-query-persist-client Patch
@tanstack/react-query-devtools Patch
@tanstack/solid-query-devtools Patch
@tanstack/svelte-query-devtools Patch
@tanstack/react-query-persist-client Patch
@tanstack/solid-query-persist-client Patch
@tanstack/svelte-query-persist-client Patch
@tanstack/react-query-next-experimental Patch
@tanstack/eslint-plugin-query Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change exports supporting types from query-core and Vue Query, adds two Vue query-option helpers, and expands type checks for option inference, cached data, and declaration output.

Changes: Vue Query option types

Layer / File(s) Summary
Export supporting types
.changeset/vue-query-export-query-options-supporting-types.md, packages/query-core/src/index.ts, packages/vue-query/src/index.ts, packages/vue-query/src/__tests__/queryOptions.test-d.ts
The package entry points export supporting query-core and Vue Query types. Type tests check that selected supporting types are available. The Changeset specifies patch releases for both packages.
Add query-option helpers and declaration checks
integrations/vue/declaration-emit/src/query-options.ts, integrations/vue/declaration-emit/consumer/query-options.ts
Two helpers resolve value, ref, or getter IDs for query keys and enablement. Declaration checks cover selected option data types, cached data types, and supporting types.
Test option and cache type inference
packages/vue-query/src/__tests__/queryOptions.test-d.ts
Type tests cover tagged options, selector inference, defined and possibly undefined useQuery data, and query-client and query-key data inference.

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

Change: Bug fix

Suggested reviewers: sukvvon, tkdodo, damianosipiuk

Merge Risk: Minimal · up to a491b

This change exports supporting types so declaration emit for query options no longer fails with TS2883. It affects only type declarations, adds no runtime behavior, and has regression tests. It is low risk to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: exporting queryOptions supporting types from query-core and vue-query, plus declaration-emit tests. The changeset, the index.ts export diffs, and the new declaration-e…
Description check Passed The description follows the repository template. It has a Changes section that explains the exported supporting types and the regression tests, and the motivation (TS2883 during declaration emit) is s…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: exporting queryOptions supporting types from query-core and vue-query, plus declaration-emit tests. The changeset, the index.ts export diffs, and the new declaration-emit and type tests all match this scope. The title uses the conventional fix(scope) form and is specific. The description is long and points at the same change, so the title is accurate.

Full details: Description check

Explanation

The description follows the repository template. It has a Changes section that explains the exported supporting types and the regression tests, and the motivation (TS2883 during declaration emit) is stated. The Checklist is filled in, and the author states a changeset was added, which matches the raw summary. The Release Impact section is not ticked, but the checklist states the changeset was added, so the release intent is still clear. The verification commands are listed with TypeScript and Vue versions. Required content is present, with only minor formatting gaps in the template checkboxes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e7916a9 and a491bb7.

Files selected for processing: 6

  • .changeset/vue-query-export-query-options-supporting-types.md
  • integrations/vue/declaration-emit/consumer/query-options.ts
  • integrations/vue/declaration-emit/src/query-options.ts
  • packages/query-core/src/index.ts
  • packages/vue-query/src/__tests__/queryOptions.test-d.ts
  • packages/vue-query/src/index.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant