@@ -4,22 +4,6 @@ type Parts<Path extends string> = Path extends `${infer Head}/${infer Tail}`
4
4
? [ Head , ...Parts < Tail > ]
5
5
: [ Path ]
6
6
7
- type BindParams <
8
- Path extends string ,
9
- Params extends Record < string , any >
10
- > = Path extends `${infer Head } /${infer Tail } `
11
- ? `${BindParam < Head , Params > } /${BindParams < Tail , Params > } `
12
- : BindParam < Path , Params >
13
-
14
- type BindParam <
15
- Elem extends string ,
16
- Params extends Record < string , any >
17
- > = Elem extends `:${infer Param } `
18
- ? Param extends keyof Params
19
- ? Params [ Param ]
20
- : Elem
21
- : Elem
22
-
23
7
type RawParams < Path extends string > = {
24
8
[ K in Parts < Path > [ number ] as K extends `:${string } ?`
25
9
? never
@@ -179,7 +163,7 @@ export default class ZodRoute<
179
163
return result . data
180
164
}
181
165
182
- format ( params : z . output < Schema > ) : BindParams < Pattern , z . output < Schema > > {
166
+ format ( params : z . output < Schema > ) : string {
183
167
const rawParams : any = this . formatSchema . parse ( params )
184
168
return this . parts
185
169
. flatMap ( ( p ) => {
@@ -193,9 +177,7 @@ export default class ZodRoute<
193
177
. join ( '/' ) as any
194
178
}
195
179
196
- partialFormat < P extends Partial < z . output < Schema > > > (
197
- params : P
198
- ) : BindParams < Pattern , P > {
180
+ partialFormat < P extends Partial < z . output < Schema > > > ( params : P ) : string {
199
181
const rawParams : any = this . partialFormatSchema . parse ( params )
200
182
return this . parts
201
183
. flatMap ( ( p ) => {
@@ -232,9 +214,9 @@ export default class ZodRoute<
232
214
} = { }
233
215
) : ZodRoute <
234
216
`${Pattern } /${Subpattern } `,
235
- // @ts -expect-error probably impossbile to get this type to work
236
217
z . ZodIntersection < Schema , Subschema > ,
237
218
z . ZodIntersection < FormatSchema , FormatSubschema > ,
219
+ // @ts -expect-error probably impossbile to get this type to work
238
220
z . ZodIntersection < PartialFormatSchema , PartialFormatSubschema >
239
221
> {
240
222
return new ZodRoute < any , any , any > (
0 commit comments