Type-Safe Client fails to infer json
field when combining path parameters with zValidator
#4206
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Based on the conversation history, you're asking me to write a GitHub issue about a Type-Safe Client bug where path parameters combined with
zValidator
for JSON validation cause type inference problems. Here's the issue:Type-Safe Client fails to infer
json
field when combining path parameters withzValidator
What version of Hono are you using?
Latest (based on current main branch)
What runtime/platform is your app running on?
All runtimes (TypeScript type inference issue)
What steps can reproduce the bug?
zValidator
for JSON validation:What is the expected behavior?
The Type-Safe Client should infer that both
param
andjson
fields are required in the request arguments, similar to how it works when multiple validators are used without path parameters.What do you see instead?
TypeScript error:
The client type inference only recognizes the
param
field and completely ignores thejson
validator.Additional information
:id
) withzValidator
for JSON validationvalidator('param', ...)
does not resolve the issueas any
allows the code to work at runtimeThe root cause appears to be in the Type-Safe Client's type inference system 2 where the schema-to-input type mapping doesn't properly merge path parameters with other validation targets when using
zValidator
.This affects the developer experience significantly as it breaks type safety for a common pattern of having authenticated endpoints with path parameters that also accept JSON payloads.
Beta Was this translation helpful? Give feedback.
All reactions