Skip to content
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 SearchParams types to Expo Router #22380

Merged
merged 1 commit into from May 6, 2023

Conversation

marklawlor
Copy link
Contributor

@marklawlor marklawlor commented May 4, 2023

Why

useLocalSearchParams in currently typed. We can not generate a helper type to convert a route to the SearchParams objects

These types are strongly connected to the generated routes and will break if a route ever changes (e.g the variable is renamed).

Relative routes are ignores and are currently considered out of scope.

// These are expected to return an empty object as there are no search parameters
SearchParams<"/">
// ^? {}
SearchParams<"/test">
// ^? {}

SearchParams<"/user/[id]">
// ^? { id: string }
SearchParams<"/team/[...id]">
// ^? { id: string[] }

One annoying downside is that the autocomplete doesn't work. This due to typescript simply not supporting it microsoft/TypeScript#34771

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label May 4, 2023
@marklawlor marklawlor force-pushed the marklawlor/useSearchParams-types branch from a2adb44 to 6c23256 Compare May 4, 2023 11:58
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels May 4, 2023
@marklawlor marklawlor force-pushed the marklawlor/useSearchParams-types branch from 6c23256 to f5ece0d Compare May 4, 2023 12:01
@marklawlor marklawlor marked this pull request as draft May 4, 2023 12:05
@marklawlor marklawlor marked this pull request as ready for review May 4, 2023 20:15
@marklawlor marklawlor merged commit 81b7a70 into main May 6, 2023
5 checks passed
@marklawlor marklawlor deleted the marklawlor/useSearchParams-types branch May 6, 2023 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants