Skip to content

Commit

Permalink
Add more inferred param types
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwgillespie committed Jun 4, 2022
1 parent fc21bca commit 87f0916
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/zap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,18 @@ export function fromRequest<Fn extends (req: ServerRequest, ...rest: any[]) => a
// TODO: can we support more param types here?
export type RouteParams<T extends string> = T extends `${string}:${infer P}?/${infer Rest}`
? {[K in P]?: string} & RouteParams<Rest>
: T extends `${string}:${infer P}*/${infer Rest}`
? {[K in P]?: string} & RouteParams<Rest>
: T extends `${string}:${infer P}+/${infer Rest}`
? {[K in P]: string} & RouteParams<Rest>
: T extends `${string}:${infer P}/${infer Rest}`
? {[K in P]: string} & RouteParams<Rest>
: T extends `${string}:${infer P}?`
? {[K in P]?: string}
: T extends `${string}:${infer P}*`
? {[K in P]?: string}
: T extends `${string}:${infer P}+`
? {[K in P]: string}
: T extends `${string}:${infer P}`
? {[K in P]: string}
: {}

0 comments on commit 87f0916

Please sign in to comment.