middleware
middleware copied to clipboard
Types of typiaValidator in typia-validator are not compatible with hono 4.x
Which middleware has the bug?
@hono/typia-validator
What version of the middleware?
0.1.0
What version of Hono are you using?
4.6.17
What runtime/platform is your app running on? (with version if possible)
Node.js
What steps can reproduce the bug?
I noticed two problems:
-
~~
typia.http.createValidateQuerydoesn’t work, it throwsTypeError: xxx.get is not a function(in the most basic case, so reproduction is trivial).~~ (My fault, I importedtypiaValidatorfrom@hono/typia-validatorinstead of@hono/typia-validator/http.) -
There’s a type error in packages/typia-validator/src/index.ts:32-51:
Type 'MiddlewareHandler<E, P, { in: { [K in Target]: K extends "json" ? unknown : { [x: string]: ValidationTargets[K][string]; }; }; out: { [K_1 in Target]: any; }; }>' is not assignable to type 'MiddlewareHandler<E, P, V>'.
Types of parameters 'c' and 'c' are incompatible.
Type 'Context<E, P, V>' is not assignable to type 'Context<E, P, { in: { [K in Target]: K extends "json" ? unknown : { [x: string]: ValidationTargets[K][string]; }; }; out: { [K_1 in Target]: any; }; }>'.
Type 'V' is not assignable to type '{ in: { [K in Target]: K extends "json" ? unknown : { [x: string]: ValidationTargets[K][string]; }; }; out: { [K_1 in Target]: any; }; }'.
Type '{ in: { [K in Target]: O; }; out: { [K in Target]: O; }; }' is not assignable to type '{ in: { [K in Target]: K extends "json" ? unknown : { [x: string]: ValidationTargets[K][string]; }; }; out: { [K_1 in Target]: any; }; }'.
Types of property 'in' are incompatible.
Type '{ [K in Target]: O; }' is not assignable to type '{ [K in Target]: K extends "json" ? unknown : { [x: string]: ValidationTargets[K][string]; }; }'.
Type 'O' is not assignable to type 'K extends "json" ? unknown : { [x: string]: ValidationTargets[K][string]; }'.
Type 'OutputType<T>' is not assignable to type 'K extends "json" ? unknown : { [x: string]: ValidationTargets[K][string]; }'.
Type 'unknown' is not assignable to type 'K extends "json" ? unknown : { [x: string]: ValidationTargets[K][string]; }'.ts(2322)
And I cannot figure out how to fix it, this type is incredibly complex.
What is the expected behavior?
No response
What do you see instead?
No response
Additional information
No response
@jirutka Thank you for raising the issue.
Hi @dworznik, can you handle this?