fix(vue-query): preserve branded types in MaybeRefDeep - #10573
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus 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 localized TypeScript change preserves branded types in Vue Query options and adds coverage for the affected inference cases; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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. |

🎯 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 types as objects, which destroyed the branded type information needed forDataTag-based overload resolution.The fix adds a terminal branch to
MaybeRefDeep:T extends { __brand: infer _ } ? T, so branded types pass through unchanged.Two type-test cases were added to validate the fix.
Fixes #9920
✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
queryKeytuples passed throughqueryOptionsanduseQuery.