SIGN IN SIGN UP
honojs / hono UNCLAIMED

Web framework built on Web Standards

0 0 78 TypeScript

fix(types): propagate middleware response types to app.on overloads (#4906)

PR #4393 introduced `MergeMiddlewareResponse<M_k>` to capture middleware responses (e.g. `c.json({ error }, 401)` returned from a preceding handler) into the inferred RPC schema. The change was applied to `HandlerInterface` (`app.get/post/...`) but `OnHandlerInterface` was not updated, so the same route declared with `app.on(method, path, ...)` or `app.on(method[], path, ...)` silently dropped middleware responses from the schema.

Bring 18 overloads (handler counts 2..10 for both single-method and method[] variants) in line with `HandlerInterface` by introducing M1..M(n-1) middleware type parameters and unioning `MergeMiddlewareResponse<M_k>` into the schema's response type.

Tests covering 1, 2, 5, and 9 middlewares for each variant are added under the existing `RPC supports Middleware responses` describe.

Follow-up to #4393 and #4865.
T
tako._.v committed
52aaaf9714b06303ce5caa655b1d80675be687e9
Parent: 76d5589
Committed by GitHub <noreply@github.com> on 5/5/2026, 9:27:17 AM