Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alexanderson1993 opened this issue Mar 7, 2025 · 5 comments
Assignees

Comments

@alexanderson1993
Copy link
Contributor

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   "/": {};
     ~~~
@hakimLyon
Copy link

hakimLyon commented Mar 9, 2025

Same issue:

Image Image Image

@gavinfaux
Copy link

gavinfaux commented Mar 9, 2025

Same issue as title, 7.3.0, using route('/', 'routes/home.tsx') instead of index('routes/home.tsx). #13140 did not resolve.

Switched to using route instead of index due to unrelated issue posting to index (still trying to figure out minimal reproduction for that). Sticking to 7.1.5 for now.

Edit: figured out the index post issue, at least in 7.1.5 have to use /?index - in 7.1.5 we get a 405 method not allowed error and console error describing issue if trying to post to just /, but in 7.2.0/7.3.0 this seems to create a CPU race/memory leak leading to application crash. Will try and provide minimal recreation in a separate issue.

@alexanderson1993
Copy link
Contributor Author

alexanderson1993 commented Mar 10, 2025

Workaround that I'm using for now:

// routes.ts
layout("routes/home.tsx", [
  index("routes/blank.tsx"),
])

// routes/blank.tsx
export default Blank() {
  return null;
}

@kevinbailey25
Copy link

Not sure if my issue is related or not, but I now have missing routes. With 7.2.0 I've updated and am using href everywhere (SOOO NICE)... but as soon as I upgrade to 7.3.0 I have a route or two missing (from the +register.ts). I've been trying to work on reproducing it in a smaller example but no luck so far. I'm using remix-flat-routes.

Just thought I'd throw this out there in case there are others seeing the same. I'll report back if I find more.

@pcattori pcattori self-assigned this Mar 10, 2025
@adam-legge-slimmingworld
Copy link

adam-legge-slimmingworld commented Mar 11, 2025

Fwiw, I've just been trying to debug a duplicate typegen'd identifier for "/" on 7.3 and think I've narrowed it down to the "fullpath" function returning "/" for the root route (since it always starts with a / and then appends the lineage) - which is then duplicated with the "/" path I've got for my top-level layout route. I can see the filtering fix in #13140 is doing its job and filtering out the index route inside my layout route but it doesn't resolve the duplication with the root route.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants