-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Rework ExpoRouter HrefObject #23507
Merged
marklawlor
merged 7 commits into
main
from
marklawlor/cli/typed-routes/rework-hrefobject
Jul 15, 2023
Merged
Rework ExpoRouter HrefObject #23507
marklawlor
merged 7 commits into
main
from
marklawlor/cli/typed-routes/rework-hrefobject
Jul 15, 2023
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
Marklawlor/cli/typed routes/rework hrefobject
Rework ExpoRouter HrefObject
Jul 13, 2023
…b.com:expo/expo into marklawlor/cli/typed-routes/rework-hrefobject
EvanBacon
approved these changes
Jul 14, 2023
byCedric
pushed a commit
that referenced
this pull request
Jul 18, 2023
# Why Reworks how `Href` and `HrefObject` works to fix multiple issues with Expo Router types Fixes: - Issues where HrefObject required `as const` typing under some conditions (expo/router#769) - HrefObject now auto-completes all dynamic routes (previously only did static routes) - HrefObject `params` is no longer strict and can accept extra arguments - `useLocalSearchParams`/`useSearchParams`/`useGlobalSearchParams` now allow for arbitrary generics - If a route is passed as the genertic for `useLocalSearchParams`/`useSearchParams`/`useGlobalSearchParams` will return an object with keys typed for the known parameters, but still allow for arbitrary search params - Top level catch all routes (e.g `/[...missing]`) no longer cause typing to fail - e.g `<Link href="/(test)/[value]" />` will now correctly error that it should be a HrefObject and not a Href - When setting a `param` it can be a `string` or `number` - however it will always be a string when returned from `useLocalSearchParams`/`useSearchParams`/`useGlobalSearchParams` PR superseeds #23422 # Test Plan Type tests were updated but some things need to be manually tested (like autocomplete) The project generated by `npx create-expo-app@latest --template tabs@49` can be used to easily test.
EvanBacon
pushed a commit
that referenced
this pull request
Jul 19, 2023
Reworks how `Href` and `HrefObject` works to fix multiple issues with Expo Router types Fixes: - Issues where HrefObject required `as const` typing under some conditions (expo/router#769) - HrefObject now auto-completes all dynamic routes (previously only did static routes) - HrefObject `params` is no longer strict and can accept extra arguments - `useLocalSearchParams`/`useSearchParams`/`useGlobalSearchParams` now allow for arbitrary generics - If a route is passed as the genertic for `useLocalSearchParams`/`useSearchParams`/`useGlobalSearchParams` will return an object with keys typed for the known parameters, but still allow for arbitrary search params - Top level catch all routes (e.g `/[...missing]`) no longer cause typing to fail - e.g `<Link href="/(test)/[value]" />` will now correctly error that it should be a HrefObject and not a Href - When setting a `param` it can be a `string` or `number` - however it will always be a string when returned from `useLocalSearchParams`/`useSearchParams`/`useGlobalSearchParams` PR superseeds #23422 Type tests were updated but some things need to be manually tested (like autocomplete) The project generated by `npx create-expo-app@latest --template tabs@49` can be used to easily test.
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
Reworks how
Href
andHrefObject
works to fix multiple issues with Expo Router typesFixes:
as const
typing under some conditions (Link needs to be "as const" when using typedRoutes router#769)params
is no longer strict and can accept extra argumentsuseLocalSearchParams
/useSearchParams
/useGlobalSearchParams
now allow for arbitrary genericsuseLocalSearchParams
/useSearchParams
/useGlobalSearchParams
will return an object with keys typed for the known parameters, but still allow for arbitrary search params/[...missing]
) no longer cause typing to fail<Link href="/(test)/[value]" />
will now correctly error that it should be a HrefObject and not a Hrefparam
it can be astring
ornumber
- however it will always be a string when returned fromuseLocalSearchParams
/useSearchParams
/useGlobalSearchParams
PR superseeds #23422
Test Plan
Type tests were updated but some things need to be manually tested (like autocomplete)
The project generated by
npx create-expo-app@latest --template tabs@49
can be used to easily test.