fix(query-core): setQueryData updater keeps discriminated-union members when spreading a narrowed value - #11915
boriskozak wants to merge 1 commit into
Conversation
…rs when spreading a narrowed value
🦋 Changeset detectedLatest commit: 45540d1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 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 |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
ChangessetQueryData updater typing
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to This compile-time API improvement supports tagged-union narrowing in setQueryData without an identified merge-blocking risk. Security Architecture ReviewSecurity architecture risk: ⚪ Minimal · up to The change improves callback typing without changing runtime cache access, update behavior, or authority. No material security risk introduced or worsened by this PR was identified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
🚥 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 |
🎯 Changes
setQueryDatatyped the updater's input asNoInfer<TInferredQueryFnData> | undefined. WithNoInferin the input position, a narrowed discriminated union lost its variant-specific fields when spread inside the updater, so this failed with TS2345:The fix drops
NoInferfrom the updater's input position (TInferredQueryFnData | undefined) while keeping it on the return position and the method's return type, so inference from the tagged query key still flows the same way. One-line type change inqueryClient.ts, plus a type-level regression test and a changeset.Also fixes #11794 (same root cause).
✅ Checklist
pnpm run test:pr(see notes below).pnpm run test:prnotes: 134 tasks passed, including alltest:typestargets (TS 5.6 through 7.0 across affected packages),test:eslint,test:build, andbuild. Five failures are unrelated to this change:query-devtools:test:libandeslint-plugin-query:test:libpass on re-run (flaky under parallel nx);angular-query-experimental:test:libfails identically on clean main (Angular TestBed environment issue: "Cannot set base providers because it has already been called");root:test:knipandroot:test:docsfail because this checkout is missingexamples/**andintegrations/**.🚀 Release Impact
Fixes #11795
Summary by CodeRabbit
setQueryDataupdater functions, allowing discriminated union data to be narrowed and updated while accounting for possibly undefined data.