Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/green-jeans-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hono/zod-validator": patch
---

Fix Hono RPC type inference when using zValidator with partial schemas.
10 changes: 3 additions & 7 deletions packages/zod-validator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
c: Context<E, P>
) => Response | void | TypedResponse<O> | Promise<Response | void | TypedResponse<O>>

type HasUndefined<T> = undefined extends T ? true : false

Check failure on line 34 in packages/zod-validator/src/index.ts

View workflow job for this annotation

GitHub Actions / build

'HasUndefined' is declared but never used.

type ExtractValidationResponse<VF> = VF extends (value: any, c: any) => infer R
? R extends Promise<infer PR>
Expand All @@ -52,13 +52,9 @@
: never

type DefaultInput<Target extends keyof ValidationTargets, In, Out> = {
in: HasUndefined<In> extends true
? {
[K in Target]?: [In] extends [ValidationTargets[K]] ? In : InferInput<In, K>
}
: {
[K in Target]: [In] extends [ValidationTargets[K]] ? In : InferInput<In, K>
}
in: {
[K in Target]: [In] extends [ValidationTargets[K]] ? In : InferInput<In, K>
}
out: { [K in Target]: Out }
}

Expand Down
Loading