Type-Safe Links #14365
Closed
distinctdan
started this conversation in
Proposals
Type-Safe Links
#14365
Replies: 2 comments 4 replies
-
You can use the |
Beta Was this translation helpful? Give feedback.
2 replies
-
This should really be documented. How do you feel about me opening a bug report to fix the docs? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was surprised to discover there isn't any way to generate a Link url safely. React Router is already generating types for the route params. Is there any reason not to also generate a function that can build the URL with typesafe parameters? In this day and age of type safety, I don't see any reason to expose my app to possible programmer mistakes. If I make a typo in a URL, I expect the compiler to tell me about it. And since react router is already scraping all the route params, all of the information should already be available to generate such a function. It would also be opt-in, so this wouldn't be a breaking change.
Example use:
As a workaround, I'm considering building a big object of URL generators for all my routes, but that's kind of inconvenient, and it will have to be updated continually as we change routes.
Beta Was this translation helpful? Give feedback.
All reactions