Skip to content

Incorrect type on routeTree.children #4766

Open

Description

@Dan503

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

Activity

  1. LadyBluenotes commented on Jul 15, 2026

    @LadyBluenotes
    Member

    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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    typesChanges to the typescript types

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions