-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
feat(react-router): parse regex to calculate accurate types for generatePath
#13436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
feat(react-router): parse regex to calculate accurate types for generatePath
#13436
Conversation
|
Hi @devonpmack, Welcome, and thank you for contributing to React Router! Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once. You may review the CLA and sign it by adding your name to contributors.yml. Once the CLA is signed, the If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run. Thanks! - The Remix team |
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
39091da
to
1dc814b
Compare
generatePath
@markdalgleish Hey Mark would it be possible to get this reviewed 🙏 Not sure who would be best to ping. Thank you! |
generatePath
generatePath
When calling
generatePath('/pages/:page(comments|latest_activity)')
by parsing the regex, we should be able to automatically enforce that thepage
parameter is one ofcomments | latest_activity
.This PR implements that parsing:
If the path contains regex symbols like
:page(\d+|activity)
then it will not try to parse the types.This could be a breaking change if anyone is incorrectly calling generatePath with arguments that aren't part of the
(|)
in the regexp.