Skip to content

Commit

Permalink
fix: repair extraction of route name for useSafeParams when `search…
Browse files Browse the repository at this point in the history
…Params` exists
  • Loading branch information
lukemorales committed Mar 30, 2024
1 parent 0634241 commit 4f0e3a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-cooks-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"next-safe-navigation": patch
---

Fix type definition for `useSafeParams` when route has both `params` and `searchParams` defined
10 changes: 6 additions & 4 deletions src/create-navigation-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ type SafeRoute<

type RouteWithParams<Config extends NavigationConfig> = {
[Route in keyof Config & string]: Config[Route] extends (
| RouteBuilder<string, infer Params extends z.ZodSchema, never>
| RouteBuilder<string, infer Params extends z.ZodSchema, any>
RouteBuilder<string, infer Params extends z.ZodSchema, infer _>
) ?
Params extends z.ZodSchema ?
Route
Expand All @@ -90,8 +89,11 @@ type RouteWithParams<Config extends NavigationConfig> = {

type RouteWithSearchParams<Config extends NavigationConfig> = {
[Route in keyof Config & string]: Config[Route] extends (
| RouteBuilder<string, never, infer Search extends z.ZodSchema>
| RouteBuilder<string, any, infer Search extends z.ZodSchema>
RouteBuilder<
string,
infer _ extends z.ZodSchema,
infer Search extends z.ZodSchema
>
) ?
Search extends z.ZodSchema ?
Route
Expand Down

0 comments on commit 4f0e3a5

Please sign in to comment.