Skip to content

Commit bfa587f

Browse files
fix: corrected the types for describeResponse (#191)
1 parent 866eab4 commit bfa587f

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/__tests__/zodv4.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,13 @@ describe("zod v4", () => {
8888
}),
8989
validator("json", z.object({ message: z.string() })),
9090
describeResponse(
91-
(c) => {
92-
return c.json({ error: "some" }, 400);
91+
async (c) => {
92+
try {
93+
return c.json({ message: "Hello World" }, 200);
94+
} catch (e) {
95+
console.error(e);
96+
return c.json({ error: e.message }, 400);
97+
}
9398
},
9499
{
95100
200: {

src/middlewares.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,16 @@ type HandlerResponse<
148148
T extends Partial<Record<StatusCode, StandardSchemaV1>> = Partial<
149149
Record<StatusCode, StandardSchemaV1>
150150
>,
151-
> = {
152-
[K in keyof T]: T[K] extends StandardSchemaV1
153-
? PromiseOr<
154-
TypedResponse<
151+
> = PromiseOr<
152+
{
153+
[K in keyof T]: T[K] extends StandardSchemaV1
154+
? TypedResponse<
155155
StandardSchemaV1.InferOutput<T[K]>,
156156
Num<K> extends StatusCode ? Num<K> : never
157157
>
158-
>
159-
: never;
160-
}[keyof T];
158+
: never;
159+
}[keyof T]
160+
>;
161161

162162
export type Handler<
163163
E extends Env,

0 commit comments

Comments
 (0)