Repository navigation
fix(vue-query): accept getters of query-core options in useQuery and useInfiniteQuery - #10
Closed
benjavicente wants to merge 7 commits into
Closed
benjavicente wants to merge 7 commits into
benjavicente wants to merge 7 commits into
Conversation
…Query Options from query-core carry a tagged key, which DeepUnwrapRef turns into an object, and Query is invariant in its key type. New overloads keep the key bare so it is inferred from the callbacks. They come after the Vue overloads, so options those accept resolve as before. The Vue fallback is repeated last to keep `Parameters<typeof useQuery>`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🚀 Changeset Version Preview2 package(s) bumped directly, 22 bumped as dependents. 🟨 Minor bumps
🟩 Patch bumps
|
Accepting plain objects, refs and computeds let options the Vue overloads reject fall through, so callbacks typed with a ref in the key compiled even though they receive the unwrapped key at runtime. Getters are also how the other adapters take reactive options, and a key containing a ref is now rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Checking that the key was assignable to its unwrapped type let `Ref<object>` through, since a Ref is an object. Checking the other direction catches it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`@tanstack/vue-query` is in the same fixed group as `@tanstack/query-core`, so it takes the same minor bump. The docs section is left out of this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A zero-argument `enabled` is a Vue getter, so its cached result goes stale for state Vue doesn't track, and `cloneDeep` overflows on cyclic objects and skips symbol keys. Comments mark both where they happen, and an `it.fails` test states the wanted `enabled` behaviour, so it goes red once that is fixed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comments are enough for a case this rare. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Landed on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Changes
Lets
useQueryanduseInfiniteQueryaccept a getter of options from@tanstack/query-core, the same way the other adapters take them, so Vue gets the shared options from TanStack#10973.useQueries,useMutation, and the imperative client already accept them directly, and this adds tests for those.TQueryKeyis inferred from core's callbacks.DeepUnwrapRefbreaks tagged keys, andQueryis invariant in its key.Parameters<typeof useQuery>.refis rejected, because callbacks receive the unwrapped key at runtime.Two recent changes on
mainmade this possible: TanStack#12542 is the runtime change this needed, since Vue now passes the query toenabled(query)callbacks, and TanStack#12525 also improved the types for shared options in the imperative client methods.Limits:
useQuery(coreOptions)without a getter stays rejected before TS 7.1. Generic keys such as['todo', id]withid: Tstay rejected, as onmain. A getter function inside a core key isn't rejected.✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Fork review PR, stacked on
query-mutation-options-in-core. The description needs rewriting in your own voice before opening upstream, perAI_POLICY.md.🤖 Generated with Claude Code