Discussion about ToOptions Interface: How to `params`, `from` and `to` play together?
@Manuel Schiller, would be good to have your input on this, because you were also the one providing me feedback on https://github.com/TanStack/router/issues/5582#issuecomment-3455690810
I went through the docs and got the impression that docs are already quite comprehensive - I think I'm just missing a few more examples here and there.
I found the following guidelines - although maybe too inconspicuous:
* If you know the route, use it as
from (safest to use Route.fullPath).
* If you don't know the route, don't provide a from and TypeScript will guide you.
I think that - equiped with these two guidelines - I can build something that's safe, except this case:
Imagine, I don't know the route (it's a shared component), and I want to create a link:
Another example using functional style, where I skip what I get as parameters of the previous route, where one might be even more sure the id wouldn't be taken over:
This link will work in all cases, except if I'm on a route that already has the id prop. This way, I have to be quite knowledgeable about the place I am. This might have worked prior to the introduction of optional parameters, because TypeScript requires me to set the companyId (I could also have that left out and it would work, despite TypeScript complaining).
I don't know what a good solution here could be, but one thought was to make all keys of a route required in the params. This might break with existing definitions, but would at least make clear what value should be set, in the case that a user doesn't provide a from. IF he provides a from, we can expect that he knows what he's doing.Navigation | TanStack Router React Docs
Everything is Relative Believe it or not, every navigation within an app is relative, even if you aren't using explicit relative path syntax (../../somewhere). Any time a link is clicked or an imperat...
GitHub
URL-Params are kept even if not provided requiring TypeScript error...
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...
0 Replies