Skip to content
Source
Sign inSign up
TanStack/query

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

Open2tsoftwareapp(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/12723/headopened View on GitHub

2tsoftwareapp(GitHub profile, opens in a new tab)commented

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.
    1. 🦋 Changeset detected

      Latest commit: a491bb7fd965992b7b21976e1aadaef4d91f1b6b

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

      This PR includes changesets to release 26 packages
      NameType
      @tanstack/query-corePatch
      @tanstack/vue-queryPatch
      @tanstack/angular-queryPatch
      @tanstack/lit-queryPatch
      @tanstack/preact-queryPatch
      @tanstack/query-async-storage-persisterPatch
      @tanstack/query-broadcast-client-experimentalPatch
      @tanstack/query-devtoolsPatch
      @tanstack/query-persist-client-corePatch
      @tanstack/query-sync-storage-persisterPatch
      @tanstack/react-queryPatch
      @tanstack/solid-queryPatch
      @tanstack/svelte-queryPatch
      @tanstack/vue-query-devtoolsPatch
      @tanstack/angular-query-devtoolsPatch
      @tanstack/angular-query-persist-clientPatch
      @tanstack/preact-query-devtoolsPatch
      @tanstack/preact-query-persist-clientPatch
      @tanstack/react-query-devtoolsPatch
      @tanstack/solid-query-devtoolsPatch
      @tanstack/svelte-query-devtoolsPatch
      @tanstack/react-query-persist-clientPatch
      @tanstack/solid-query-persist-clientPatch
      @tanstack/svelte-query-persist-clientPatch
      @tanstack/react-query-next-experimentalPatch
      @tanstack/eslint-plugin-queryPatch

      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

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      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 nameStatusExplanation
      Title checkPassedThe 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 checkPassedThe 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 checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck 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 e7916a9e2eb695531fe3aa7bc9983e3bc734889a and a491bb7fd965992b7b21976e1aadaef4d91f1b6b.

      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.

Sign in to join this conversation.