Skip to content
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

hono/client is not inferring input types when using zValidator on route #996

Open
puerschel93 opened this issue Mar 2, 2025 · 1 comment
Labels

Comments

@puerschel93
Copy link

Which middleware has the bug?

@hono/zod-validator

What version of the middleware?

0.4.3

What version of Hono are you using?

4.6.16

What runtime/platform is your app running on? (with version if possible)

Bun@1.1.2

What steps can reproduce the bug?

Set up a nested router.

const testRouter = new Hono().get(
   "/test",
    zValidator(
        "json",
        z.object({
            test: z.string(),
        }),
    ),
    async (c) => {
        return c.json({ success: true });
    },
);

export { testRouter };

Include it in the root Router. (No other middlewares are used so far)

const app = new Hono()
    .route("/test", testRouter);

export const routes = route;

Then use the hono/client within the server project and on the client side to test the outcome.

What is the expected behavior?

When I use the hono/client in my server project it infers the inputs just fine:

Image

What do you see instead?

But when I use the exact same types etc. it does not infer the args correctly.

Image

Additional information

When I use the default validator function provided by Hono it works just fine. But even when I wrap that function to create my own kind of zValidator it breaks and has the same behavior as mentioned before.

My .tsconfigs are setup properly and all the routes and stuff gets inferred as expected.

I appreciate any help.

@yusukebe
Copy link
Member

yusukebe commented Mar 2, 2025

@puerschel93

I can't reproduce it. Can you share a minimal project to reproduce it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants