Skip to content
Source
Sign inSign up
TanStack/router

Incorrect type on `routeTree.children` #4766

Send to my agent
OpenDan503(GitHub profile, opens in a new tab) opened this issue 1 comment

Which project does this relate to?

Router

Describe the bug

routeTree.children has the type RootRouteChildren | undefined

If you type routeTree.children. You get the route key names as options

Image

However in the browser, if you console.log(routeTree.children) you get an array:

Image

I want to be able to generate a navigation by looping over all of the root routs. This gets in the way of that.

Your Example Website or App

https://stackblitz.com/edit/github-bii6hl4v?file=src%2Froutes%2Fabout.tsx

Steps to Reproduce the Bug or Issue

Set up some routes and then try to access the data from routeTree.children

Expected behavior

The actual type for routeTree.children should match the type that TS says it is.

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.121.2
  • OS: Windows 11
  • Bundler: vite 6.1.0

Additional context

No response

  1. Confirmed this is still present on current main. Generated route children use a keyed object for type inference, but _addFileChildren stores Object.values(children) at runtime. This leaves routeTree.children typed as an object even though its runtime value is an array.

    The object representation was introduced for TypeScript performance in #1564, so a fix will need to preserve that type-level structure while correctly typing the runtime children property.

    Keeping this open as a types bug.

Sign in to join this conversation.