Open cybercoder-naj opened 1 month ago
Hi @cybercoder-naj
I can't understand your problem. The res.status
will be 500 or 200, so it's no problem.
The middleware returns status code 500 but the route handler itself only returns 200. So when I'm trying to test the app with the route and assert the status code, Typescript only allows me to test on 200. Is that making sense?
Since the route handler only returns a status code of 200, res.status
in the test doesn't have type 200 | 500
. The type is simply 200
.
Either I have to add // @ts-ignore
or let vscode show it's a Typescript error
@cybercoder-naj
Ah! It's about TypeScript types! You are right. It's like a bug but a known issue similar to https://github.com/honojs/middleware/issues/580
There is no solution to remove the error immediately, but I'll find a good way. Thanks!
Yesss. It's the same issue essentially. Should I mark this closed as duplicate?
Should I mark this closed as duplicate?
No! It's a little bit difference from this issue. Let's keep it.
Hi @kosei28
What do you think of these problems? Any thoughts?
What version of Hono are you using?
4.4.9
What runtime/platform is your app running on?
Bun
What steps can reproduce the bug?
What is the expected behavior?
Consider other status codes that may be returned from middlewares or other factors.
What do you see instead?
Argument of type '500' is not assignable to parameter of type '200'
Additional information
No response