-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Closed as duplicate of#13182
Closed as duplicate of#13182
Copy link
Labels
Description
I'm using React Router as a...
framework
Reproduction
https://stackblitz.com/edit/github-ckdgdgys
- Configure
routes.tsfile, withroute('/', 'path/to/index.tsx')instead ofindex('path/to/index.tsx')route - Run
npm run typecheck .react-router/types/+register.tshas duplicate"/": {};entry- Type checking fails due to the duplicate entry
- At runtime application continues to work
System Info
System:
OS: macOS 15.1.1
CPU: (10) arm64 Apple M1 Pro
Memory: 85.75 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 23.4.0 - /opt/homebrew/bin/node
npm: 10.9.2 - /opt/homebrew/bin/npm
pnpm: 8.9.2 - /opt/homebrew/bin/pnpm
Watchman: 2024.12.02.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 134.0.6998.118
Safari: 18.1.1
npmPackages:
@react-router/dev: ^7.3.0 => 7.3.0
@react-router/node: ^7.0.0 => 7.3.0
@react-router/serve: ^7.3.0 => 7.3.0
react-router: ^7.0.0 => 7.3.0
vite: ^5.4.14 => 5.4.14Used Package Manager
npm
Expected Behavior
I see two routes of expected behaviour:
- The
react-router typegencommand recognises you are using theroutesetup for everything instead ofindex()and does not create duplicate entries in the+register.tstypes file.
OR
- Documentation on the react-router website warns consumers of the requirement to at least have a base
index()route - The
react-router typegencommand throws a descriptive error to point the user in the right direction
Option 2 may be easier to code for, since we can just check if there are NO routes with an index: true property.
Actual Behavior
react-router typegencommand creates two"/": {};entries in the.react-router/types/+register.tsfile- Subsequent type checks fail with:
.react-router/types/+register.ts:10:3 - error TS2300: Duplicate identifier '/'.
10 "/": {};
~~~
.react-router/types/+register.ts:14:3 - error TS2300: Duplicate identifier '/'.
14 "/": {};
~~~
Found 2 errors in the same file, starting at: .react-router/types/+register.ts:10
ronaldcurtis and OAndris