From 87f0916acb37b92a0def64bbbb376f8699c95aa5 Mon Sep 17 00:00:00 2001 From: Jacob Gillespie Date: Sat, 4 Jun 2022 21:02:24 +0100 Subject: [PATCH] Add more inferred param types --- src/zap.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/zap.ts b/src/zap.ts index 5b8e8ed..d631763 100644 --- a/src/zap.ts +++ b/src/zap.ts @@ -325,10 +325,18 @@ export function fromRequest a // TODO: can we support more param types here? export type RouteParams = T extends `${string}:${infer P}?/${infer Rest}` ? {[K in P]?: string} & RouteParams + : T extends `${string}:${infer P}*/${infer Rest}` + ? {[K in P]?: string} & RouteParams + : T extends `${string}:${infer P}+/${infer Rest}` + ? {[K in P]: string} & RouteParams : T extends `${string}:${infer P}/${infer Rest}` ? {[K in P]: string} & RouteParams : 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} : {}