TanStack / TanStack/router

Incorrect type on `routeTree.children`

Open
#4,766 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

types
Dominant language
TypeScript
Stars
15.1k
Forks
1.9k
Avg merge
1d 20h
Merged PRs (30d)
143

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked StackBlitz reproduction and its src/routes/about.tsx entry point, then trace how routeTree.children is typed and populated at runtime. Confirm that the declared type matches the observed array so callers can loop over root routes and generate navigation without a type mismatch.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.