fix(vue-query,query-core): export queryOptions supporting types and add declaration-emit tests #12723
main fromrefs/pull/12723/head·opened View on GitHubChanges#
Follow-up for #11042 (after #11224 resolved the duplicate UndefinedInitialQueryOptions / DefinedInitialQueryOptions export collision):
- Export supporting types referenced by
queryOptions/QueryOptions/UseQueryOptionssignatures so TypeScript does not hitTS2883when 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.tsandintegrations/vue/declaration-emit/verifying exported factory functions, spreading intoqueryOptions({ ...opts, select }),selectinference, andDataTagpreservation inqueryClient.getQueryData(queryKey). - Add a patch changeset for
@tanstack/query-coreand@tanstack/vue-query.
Verification#
pnpm oxfmt --checkon all changed filespnpm run test:knip && pnpm run test:sherif && pnpm run test:docspnpm 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 withskipLibCheck: 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-coreand@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
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.tsThe 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.tsTwo 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.tsType tests cover tagged options, selector inference, defined and possibly undefined useQuerydata, 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 toa491b-
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:
4-
Check name Status Explanation Title check 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 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 Check skipped because no linked issues were found for this pull request. Out of Scope Changes check 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.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: TanStack/query
- Branch: main
- File: .coderabbit.yaml
- Commit: e7916a9
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Advanced
- Run ID:
cd21c027-6e2a-4e0a-9aa6-3e92a9b4f88c
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.mdintegrations/vue/declaration-emit/consumer/query-options.tsintegrations/vue/declaration-emit/src/query-options.tspackages/query-core/src/index.tspackages/vue-query/src/__tests__/queryOptions.test-d.tspackages/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.
🦋 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
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