hono
hono copied to clipboard
throw errors when there is no return
What is the feature you are proposing?
hono
will throw a runtime error of Context is not finalized
if there is no return c.xxx()
, but there is no typescript check, some functions return c.body(null, 204)
, which is easy to be forgotten.
So I think if we can add some type check or eslint rules to prevent no return expression
Hi @bingtsingw
I also want to have the feature!
Currently, it throws a TypeScript error when a handler is not async.
But if it is an async function, we can't make it throw an error because we have to treat the middleware handler as the same as the handler. For example, the code should not throw an error.
app.get('/', async (c, next) => {
await next()
})
So an async handler does not throw an error.
Making it throw an error will be difficult or impossible, I think.