You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
InferProps keeps Promise and Response for a withValidator loader #478
InferProps gives the props of a defineHandler loader, but not of a defineHandler.withValidator one:
exportconstloader=defineHandler.withValidator({params: z.object({id: z.string()}),})(async(c,{ params })=>{constbook=awaitfindBook(params.id);if(!book)returnc.notFound();return{ book };});typeProps=InferProps<typeofloader>;// expected: { book: Book }// actual: Promise<Response | { book: Book }>
defineHandler returns TypedHandler<{}, Exclude<Awaited<R>, Response>>, but withValidator returns TypedHandler<V, R> with the raw R. Routes don't notice, because the generated types wrap the output in Serialize<Awaited<…>>. InferProps reads __output directly, so it breaks.
Returning Exclude<Awaited<R>, Response> from withValidator too fixes it. Fix and a type test: ashunar0@07c5352
Activity
Fix inferred props for validated handlers, closes voidzero-dev#478.
fix(handler): infer output type for defineHandler with middleware (#490)