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 Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR updates ChangesBranded queryKey inference
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 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 | 1m 32s | View ↗ |
nx run-many --target=build --exclude=examples/*... |
✅ Succeeded | 1s | View ↗ |
☁️ Nx Cloud last updated this comment at 2026-04-25 04:59:09 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

🎯 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.queryKeytuples and nested inside objects.