-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
feat: add generated types for Expo Router useSegment #22629
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
marklawlor
changed the title
feat: add generated types for useSegment
feat: add generated types for Expo Router useSegment
May 24, 2023
marklawlor
force-pushed
the
marklawlor/cli/typed-routes/useSegment
branch
from
May 24, 2023 06:46
9c8df0c
to
eed28b1
Compare
expo-bot
added
bot: passed checks
ExpoBot has nothing to complain about
and removed
bot: suggestions
ExpoBot has some suggestions
labels
May 24, 2023
EvanBacon
approved these changes
Jun 1, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approve pending better test coverage.
marklawlor
force-pushed
the
marklawlor/cli/typed-routes/useSegment
branch
4 times, most recently
from
June 24, 2023 10:29
b253fc4
to
da7e922
Compare
marklawlor
force-pushed
the
marklawlor/cli/typed-routes/useSegment
branch
from
June 24, 2023 22:39
ed8eb1c
to
42f7607
Compare
Some updates
|
EvanBacon
approved these changes
Jul 1, 2023
EvanBacon
reviewed
Jul 3, 2023
EvanBacon
reviewed
Jul 3, 2023
This was referenced Jul 6, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
useSegment
useSearchParams
typesHref<T>
Note that this is not a breaking change as the generated types are only present inside the users' cache and should not be committed. Next time the user starts the dev server they will get the new generated types.
Questions
@EvanBacon Given the route
/(app)/note/[note]/
does useSegments return the group?useSearchParams
This hook was a bit strange as its signature changed when you enabled types routes.
Without:
useSearchParams<T extends Record<string, string>(): T
With:
useSearchParams<T extends Route>(): SearchParams<T>
This PR updates the TypedRoutes version to accept either a
Route
or aRecord
. ThisRecord
is still typed checked and it must satisfy a possible SearchParams object.For example
I quite like this as it allows you to cherry-pick the param that you need.
Note that this obviously doesn't do a runtime check for it maybe be correct, but its a start.
Href
Href has a default value and by default now represents all possible Hrefs. You can use the generic to reduce it down.