8000 possible bug: standard schema introduction v3.24 breaks libraries that depend on core zod exposed types · Issue #4056 · colinhacks/zod · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

possible bug: standard schema introduction v3.24 breaks libraries that depend on core zod exposed types #4056

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

Open
malkhuzayyim opened this issue Mar 28, 2025 · 3 comments

Comments

@malkhuzayyim
Copy link

Hi, long time zod user, love the work thank you all to who contribute.

Issue Brief

I think the introductiion of the ~standard and ~validate props has broken how some libraries wrap zod functionality and extend it

I was trying out the hono middleware mentioned by cloudflare's official docs: https://github.com/honojs/middleware/tree/main/packages/zod-validator

And it no longer works due to v3.24 i believe.

The error message if you follow the exact example they mention today is:

Argument of type 'ZodObject<{ message: ZodString; }, "strip", ZodTypeAny, { message: string; }, { message: string; }>' is not assignable to parameter of type 'ZodType<any, ZodTypeDef, any>'.
  Type 'ZodObject<{ message: ZodString; }, "strip", ZodTypeAny, { message: string; }, { message: string; }>' is missing the following properties from type 'ZodType<any, ZodTypeDef, any>': "~standard", "~validate"ts(2345)

Internal Implementation of hono's zod validator can be seen here: https://github.com/honojs/middleware/blob/main/packages/zod-validator/src/index.ts

And the return type of the user's const schema = z.object({ ... }) is no longer a match

Possible Solution

Two options to patch this come to mind:

  1. return types when making schema's with z.object should also have those props "~standard" & "~validator"
  2. or make them optional on the core types until the next major release?

Thanks again, I hope this is useful.

@malkhuzayyim
Copy link
Author
malkhuzayyim commented Mar 28, 2025

I can confirm that pinning the Zod package to v3.23.8 via overrides in package.json using pnpm eliminates the error, like so:

"pnpm": {
    "overrides": {
      "zod": "3.23.8"
    }
  }

@rt-joe
Copy link
rt-joe commented Apr 2, 2025

Same here. W 78A6 e are now getting type errors on v3.24.x (I've tried up to latest 3.24.2).

missing the following properties from type 'ZodType<any, any, any>': "~standard", "~validate", openapi

openapi is coming from zod-openapi but I'm assuming it's a similar issue. Perhaps there needs to be a fix in upstream packages as well.

Like @malkhuzayyim mentioned, it's working on v3.23.8 and prior.

@rt-joe
Copy link
rt-joe commented Apr 22, 2025

I just updated to v3.24.3 and it's working again 🤷

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

No branches or pull requests

2 participants
0