-
-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type inference for c.req.json()
#3679
Comments
I found |
@tmokmss |
Hi @tmokmss Please use c.req.json<{ foo: string }>() |
@EdamAme-x @yusukebe Thanks for the guidance! |
The |
@EdamAme-x That makes sense! I just started learning hono and you helped me a lot :) thank you so much! |
What is the feature you are proposing?
When I define a route handler with the following code, the variable
foo
is infered asany
, where I want it to bestring
without additional type annotation.It appears the HonoRequest type already has enough information to infer the json type:
However
foo
is inferred as any:c.req.json<{foo:string}>()
works, but it would be great if we can avoid adding (seemingly) redundant type annotation, like howc.req.valid('query')
works.Let me know if I'm misusing something, thanks!
The text was updated successfully, but these errors were encountered: