Repository navigation
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThis PR updates ChangesBranded queryKey inference
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change updates Vue Query type inference so branded primitive query-key values can flow from queryOptions into useQuery without overload errors. No current merge-blocking risk is identified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Linked Issues checkExplanation The changes address issue Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. (1 skipped: 1 unsupported.) Full details: Description checkExplanation The description includes the change, motivation, root cause, regression coverage, issue reference, checklist, release impact, changeset information, and verification results. The unchecked AI-assistance acknowledgment is non-critical because the description is otherwise complete. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx affected --targets=test:sherif,test:knip,tes... |
❌ Failed | 2m 23s | View ↗ |
nx run-many --target=build --exclude=examples/*... |
❌ Failed | 32s | View ↗ |
☁️ Nx Cloud last updated this comment at 2026-08-22 14:22:06 UTC
Branded types (string & { __brand: string }) were being recursively mapped
by MaybeRefDeep, causing type inference failures when used in queryKey
tuples passed from queryOptions to useQuery.
Fixes TanStack#9920
df73bb9 to
af629b6
Compare
|
Hi @byungsker , I quickly looked at this and the fix preserves branded primitive types, but it also treats any object with a I think narrowing the terminal condition to branded primitive intersections ( |
|
Good catch. The I changed it to |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |

🎯 Changes
This PR fixes a TypeScript type inference issue where branded types (e.g.
string & { __brand: 'PostId' }) inqueryKeytuples cause TS2769 errors when passed fromqueryOptionstouseQuery.The root cause was
MaybeRefDeep<T>recursively mapping branded primitive types as objects, which destroyed the branded type information needed forDataTag-based overload resolution.The fix makes only primitive values terminal in
MaybeRefDeep(T extends Primitive), so branded primitive types pass through unchanged while ordinary objects continue to recursively accept refs.Regression coverage includes direct and nested branded query keys, plus an ordinary object with a
__brandproperty and a nestedref.Fixes #9920
Review follow-up
This PR incorporates the feedback from @peterbud:
T extends { __brand: infer _ }terminal condition withT extends Primitive, so an ordinary object with a__brandproperty is still recursively unwrapped.{ __brand: 'post', postId: ref('123') }.7d972a00e6c8, and the focused regression-test follow-up is inde74b2e77.MaybeRefDeepdirectly instead of coupling it to a separateDataTag/useQueryinference shape.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Verification
pnpm nx run @tanstack/vue-query:test:types --skip-nx-cache— passed.pnpm nx run @tanstack/vue-query:test:lib --skip-nx-cache— passed for Vue 2, Vue 2.7, and Vue 3: 28 test files, 319 passed, 6 skipped, no type errors.pnpm nx run @tanstack/vue-query:test:eslint --skip-nx-cache— passed with 0 errors; 5 existing cspell warnings.pnpm exec prettier --check packages/vue-query/src/types.ts packages/vue-query/src/__tests__/queryOptions.test-d.ts .changeset/branded-types-fix.md— passed.pnpm run test:prwas also run against currentmain; the changed Vue Query targets passed, while the full run stopped atvue-declaration-emit:test:types(@babel/typesunavailable locally) androot:test:knip(generated.tsupdeclaration outputs). Neither failure involves files changed by this PR.Summary by CodeRabbit
queryKeytuples passed throughqueryOptionsanduseQuery.