Enforcing strict types for Hono's c.json() responses? #3331
Unanswered
bennobuilder
asked this question in
Q&A
Replies: 1 comment
-
Discord: https://discord.com/channels/1011308539819597844/1278377476929617971 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is it possible to enforce strict typing for Hono's
c.json()
responses at a top level (hono.Handler<..>
)?Currently, I can define expected response types like this:
This provides suggestions in
c.json({...})
, but doesn't raise a type error for mismatched types (The IDE gives suggestions though, see video):Hono's internal types for quick reference:
Discord: https://discord.com/channels/1011308539819597844/1278377476929617971
Video: https://youtu.be/LRKzHD3RAa4
Example: https://github.com/builder-group/community/blob/develop/examples/openapi-router/express/petstore/src/router.ts
Code: https://github.com/builder-group/community/blob/develop/packages/openapi-router/src/types/features/hono.ts
Beta Was this translation helpful? Give feedback.
All reactions