Skip to content

Using route("/", "routes/home.tsx") messes up auto-generated types, creating a type error #13182

Closed
@alexanderson1993

Description

@alexanderson1993

I'm using React Router as a...

framework

Reproduction

Go to https://stackblitz.com/edit/github-t35rc7ny?file=app%2Froutes.ts
Note the route has been changed from index to route('/'...
In the command line, run npm run typecheck

System Info

System:
    OS: macOS 15.1.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 104.84 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.6.0 - /opt/homebrew/bin/node
    Yarn: 4.5.3 - /opt/homebrew/bin/yarn
    npm: 10.9.2 - /opt/homebrew/bin/npm
    pnpm: 8.15.5 - /opt/homebrew/bin/pnpm
    bun: 1.2.0 - ~/.bun/bin/bun
    Watchman: 2024.12.02.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 133.0.6943.142
    Safari: 18.1.1
  npmPackages:
    @react-router/dev: ^7.3.0 => 7.3.0 
    @react-router/node: ^7.3.0 => 7.3.0 
    @react-router/serve: ^7.3.0 => 7.3.0 
    react-router: ^7.3.0 => 7.3.0 
    vite: ^5.4.11 => 5.4.14

Used Package Manager

npm

Expected Behavior

It should properly pass type checking without throwing any errors.

Actual Behavior

It throws the following error:

.react-router/types/+register.ts:11:3 - error TS2300: Duplicate identifier '/'.

11   "/": {};
     ~~~

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions