Repository navigation
fix(router-core): type route.children as the array stored at runtime - #8988
shivamlaur022 wants to merge 1 commit into
Conversation
`addChildren` and `_addFileChildren` accept children as an object (the generated route tree passes one) but store `Object.values(children)`. `route.children` was typed as the object, so `routeTree.children` offered the child route names instead of array methods. Type it as an array of the object's values; `types.children` keeps the object for inference. Fixes TanStack#4766 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 76c0424 The changes in this PR will be included in the next version bump. This PR includes changesets to release 23 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 |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
🎯 Changes
Fixes #4766.
addChildren/_addFileChildrenstoreObject.values(children)when given an object (as the generated route tree does), butroute.childrenwas typed as the object. SorouteTree.childrenautocompleted route names and.mapdidn't type-check.childrenis nowResolveRouteChildren<TChildren>: an array of the values for object children, the same tuple for array children.types.childrenstill keeps the object, so inference (and the perf win from #1564) is unchanged.Added a type test in
react-router/tests/route.test-d.tsx(fails onmain, passes here).test:typespasses on TS 5.6–7.0 for router-core and react-router.Prepared with AI assistance (Claude Code), reviewed and tested by me.
✅ Checklist
🚀 Release Impact
Summary by CodeRabbit