-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Which project does this relate to?
Router
Describe the bug
Since required parameters are also required on the params-prop of the Link component, I would expect those not being present to be removed.
In the stackblitz example, I defined a route as /users/{-$id} and added some links to it:
- Menu - without
paramsprop. - Link "User1" - having
paramsprop settingidto1. - Link "User2" - having
paramsprop settingidto2. - Link "List (not working 😬)" - having
paramsprop with an empty object. - Link "List (working 🤩)" - having
paramsprop settingidtoundefined.
The last option is invalid when having exactOptionalPropertyTypes enabled in your TypeScript config.
When imagining a different scenario, where I have multiple variables, some of them required, I can actually (against the types) leave out parameters already provided by the former route. In my real-world scenario I try to build a link to and from /company/$companyId/users/{-$userId}. Based on the types I have to provide companyId, but based on the implementation, I don't have to, but I should set userId to undefined if I want to remove it, which creates a TypeScript error, because I have exactOptionalPropertyTypes enabled.
Your Example Website or App
Steps to Reproduce the Bug or Issue
- Go to "Users".
- Click on "User1" to set the optional parameter.
- Try to get back to the "Users" page by clicking in the menu.
Expected behavior
The "List (not working 😬)" should work, means, parameters, not set when providing params should be omitted.
Screenshots or Videos
No response
Platform
- Router Version: 1.133.22
- OS: macOS
- Browser: Chrome
- Browser Version: 140
- Bundler: vite
- Bundler Version: 7.1.7