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
[router]: change Href to not be generic / use expo-router package for tests #27690
Conversation
@@ -1,46 +1,38 @@ | |||
import { getTypedRoutesDeclarationFile } from 'expo-router/build/typed-routes/generate'; |
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.
@EvanBacon I think this will break with your incoming changes. Please let me know what I should change it to
dynamicRoutes: string[]; | ||
dynamicRouteTemplates: string[]; | ||
}; | ||
function getMockContext(context: string[]) { |
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.
We don't need a real context here. The helpers inside Expo Router are not publicly exposed, and trying to access them is a commonjs/esm hassle.
ba2f44c
to
ff64a41
Compare
ff64a41
to
3fb5cd3
Compare
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
3fb5cd3
to
f77cd3b
Compare
Why
There PR is multiple fixes for typed routes
Expo Router now provides the utility functions to generate the
.d.ts
file used for typed routes. This PR changes the@expo/cli
tests to generate the fixture file using these functions.Href<T>
toHref
I've personally had some issues with using custom components wrapped in
fowardRef
that useHref
for a prop.forwardRef
doesn't work well with generic components, so I've refactored the types soHref
is no longer generic.Not only does this fix this issue, it improves the editor autocomplete when inferring the
Href
value./(groups)/
in typed routes.Technically they were always allowed, but partial routes are allowed. For example you can do
/(group1)/(group2)/page
or simply/(group1)/page
or even just/page
.Href
can be assigned to as expected.With the changes to
Href
I've added new set to tests to ensure users can assign values toHref
as expected.How
Test Plan
Checklist
npx expo prebuild
& EAS Build (eg: updated a module plugin).