Link `to` prefix helper and typescript
My application supports a single to have access to multiple teams. Almost all links in the application will be links to the same
/team/$slug prefix. I am trying to build a Link helper but I am struggling in navigating the types to play nice with my component. Any direction would be appreciated.
Example component:
5 Replies
foreign-sapphire•11mo ago
Custom Link | TanStack Router React Docs
While repeating yourself can be acceptable in many situations, you might find that you do it too often. At times, you may want to create cross-cutting components with additional behavior or styles. Yo...
foreign-sapphire•11mo ago
btw looks like you need a relative link
correct-apricotOP•11mo ago
Thanks for the quick response. I did check the docs. Those work great for adding props to the resulting element, but do not help much in constructing a
to value thats typed appropriately. But you know what, as alwasy when you ask a question the answer may come to you. GIve me a few min and get back.
Im 1000% sure there is a better way but in case anyone else stubles across this, its how I unblocked myself.
foreign-sapphire•11mo ago
how about
@Chris Horobin can we allow to specify e.g.
TFrom for ValidateLinkOptions ?
I just duplicated the type, but I hope there is a solution with even less codeafraid-scarlet•11mo ago
You can. You just need an intersection.
ValidateLinkOptions<TOptions & { from: TFrom }>