-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Closed as not planned
Closed as not planned
Copy link
Labels
Description
I'm using React Router as a...
library
Reproduction
- Go to https://stackblitz.com/edit/github-sedw5gxm?file=app%2Froutes%2Fhome.tsx
- Click "Click me"
- Observe: Navigation back occurs correctly
- Re-open https://stackblitz.com/edit/github-sedw5gxm?file=app%2Froutes%2Fhome.tsx or navigate forward
- Open
home.tsx - Observe: The manual type cast to the
toproperty - Remove the type cast
- Observe: Type error for the
toproperty
System Info
System:
OS: macOS 15.1
CPU: (12) arm64 Apple M4 Pro
Memory: 151.52 MB / 24.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.13.1 - ~/.volta/tools/image/node/22.13.1/bin/node
npm: 10.9.2 - ~/.volta/tools/image/node/22.13.1/bin/npm
pnpm: 9.15.0 - ~/.volta/bin/pnpm
bun: 1.1.38 - /opt/homebrew/bin/bun
Browsers:
Chrome: 133.0.6943.142
Safari: 18.1
npmPackages:
@react-router/dev: ^7.1.1 => 7.1.3
@react-router/node: ^7.1.1 => 7.1.3
@react-router/serve: ^7.1.1 => 7.1.3
react-router: ^7.1.1 => 7.1.3
vite: catalog: => 6.0.11Used Package Manager
pnpm
Expected Behavior
Developers can assign a number to the to property of Link to do delta navigation.
<Link to={-1}>Click me</Link>Actual Behavior
The Link component only supports a string type for the to property, while being built around the history API that supports the delta usage.
The runtime behavior is correct with this usage:
<Link to={-1 as unknown as string}>Click me</Linkhowever developers shouldn't need to cast around the restrictive types.