Type safety in middleware?
Hi, it's there a way to get the types right here?
I expected data to be
But actually it is
6 Replies
https://hono.dev/docs/guides/rpc#status-code
you can narrow the type client side using
response.ok
or response.status
for just the types, you can use hono's InferResponseType
utility type, which accepts an optional status code param that narrows the returned unionyou can't narrow a type that isn't present...
found this https://github.com/honojs/hono/issues/3746
GitHub
MiddlewareHandler response type inference · Issue #3746 · honojs/ho...
What is the feature you are proposing? When we use middleware, it can return a Response object or a Typed Response, for example, @hono/validator returns a MiddlewareHandler that can return a respon...
ah yeah, my bad. definitely didn't read your snippets closely enough
i remember seeing the response type from the middleware in the json and thinking "huh, ig that works after all"
it's okay, I think it is a well known issue so I have to find another way
thanks for the help 😄
yeah, i was just chatting w someone else who had the same issue
np!