-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
[Types]: Narrow types of hash
and search
returned by useLocation
#11254
Labels
Comments
Yeah I think that makes sense - want to push up a PR? |
Sure thing! What kind of type do you have in mind for
|
I would just do the first one to keep it simple. Query strings don't require |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe what's incorrect/missing in the documentation
Hello,
The documentation comment for
useLocation().hash
states:If this is a strict rule, it would be convenient if these values could be typed as
'' | `#${string}`
instead ofstring
. This is especially useful ifhash
is passed along to another function that impose a stricter input type, and will allow us to avoid anif
/else
clause or having to type cast.Likewise, the documentation comment for
useLocation().search
states:So this value could be typed as
'' | `?${string}`
instead ofstring
. (Alternatively,'' | `?${string}=${string}`
or'' | `?${string}=${string}` | `?${string}=${string}&${string}=${string}`
would be valid too. However, this would probably add unnecessary confusion because it doesn’t suggest that the string can contain multiple&${string}=${string}
segments).I’m willing to submit a PR
The text was updated successfully, but these errors were encountered: