@@ -17,13 +17,24 @@ export type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD";
1717export type ResolveMethod < M > =
1818 M extends Array < infer U > ? U : M extends "*" ? HTTPMethod : M ;
1919
20+ /**
21+ * Resolve a $Infer value: if it's a StandardSchemaV1 schema, extract the
22+ * output type; otherwise use as-is.
23+ */
24+ type ResolveInferValue < T > = T extends StandardSchemaV1
25+ ? StandardSchemaV1 . InferOutput < T >
26+ : T ;
27+ type ResolveInferValueInput < T > = T extends StandardSchemaV1
28+ ? StandardSchemaV1 . InferInput < T >
29+ : T ;
30+
2031/**
2132 * Resolves a body schema to its output type.
2233 */
2334export type ResolveBody < S , Meta = undefined > = Meta extends {
2435 $Infer : { body : infer B } ;
2536}
26- ? B
37+ ? ResolveInferValue < B >
2738 : S extends StandardSchemaV1
2839 ? StandardSchemaV1 . InferOutput < S >
2940 : any ;
@@ -34,7 +45,7 @@ export type ResolveBody<S, Meta = undefined> = Meta extends {
3445export type ResolveQuery < S , Meta = undefined > = Meta extends {
3546 $Infer : { query : infer Q } ;
3647}
37- ? Q
48+ ? ResolveInferValue < Q >
3849 : S extends StandardSchemaV1
3950 ? StandardSchemaV1 . InferOutput < S >
4051 : Record < string , any > | undefined ;
@@ -45,7 +56,7 @@ export type ResolveQuery<S, Meta = undefined> = Meta extends {
4556export type ResolveBodyInput < S , Meta = undefined > = Meta extends {
4657 $Infer : { body : infer B } ;
4758}
48- ? B
59+ ? ResolveInferValueInput < B >
4960 : S extends StandardSchemaV1
5061 ? StandardSchemaV1 . InferInput < S >
5162 : undefined ;
@@ -56,7 +67,7 @@ export type ResolveBodyInput<S, Meta = undefined> = Meta extends {
5667export type ResolveQueryInput < S , Meta = undefined > = Meta extends {
5768 $Infer : { query : infer Q } ;
5869}
59- ? Q
70+ ? ResolveInferValueInput < Q >
6071 : S extends StandardSchemaV1
6172 ? StandardSchemaV1 . InferInput < S >
6273 : Record < string , any > | undefined ;
@@ -67,7 +78,7 @@ export type ResolveQueryInput<S, Meta = undefined> = Meta extends {
6778export type ResolveErrorInput < S , Meta = undefined > = Meta extends {
6879 $Infer : { error : infer E } ;
6980}
70- ? E
81+ ? ResolveInferValueInput < E >
7182 : S extends StandardSchemaV1
7283 ? StandardSchemaV1 . InferInput < S >
7384 : undefined ;
0 commit comments