-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Closed
Labels
Description
I'm using React Router as a...
framework
Reproduction
Just create a route with a dynamic path and then use the useParams hook:
import type { Info } from '.react-router/types/app/routes/path/to/your/route/+types';
// ...
const params = useParams<Info['params']>();System Info
System:
OS: macOS 15.3.2
CPU: (8) arm64 Apple M1 Pro
Memory: 86.42 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
Watchman: 2024.12.02.00 - /opt/homebrew/bin/watchman
Browsers:
Brave Browser: 134.1.76.73
Chrome: 134.0.6998.89
Safari: 18.3.1
npmPackages:
@react-router/dev: ^7.3.0 => 7.3.0
@react-router/node: ^7.3.0 => 7.3.0
@react-router/remix-routes-option-adapter: ^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.14Used Package Manager
npm
Expected Behavior
TypeScript should now that params contains the dynamic path value from Info (e.g. lang or whatever the parameters on your route are.)
Actual Behavior
useParams uses a Partial and the parameter can be undefined, even though it must always be set on the Route.