10000 v4, core 0.11: `z.object()` no longer extends `z.core.$ZodObject` · Issue #4317 · colinhacks/zod · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

v4, core 0.11: z.object() no longer extends z.core.$ZodObject #4317

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

Closed
RobinTail opened this issue May 4, 2025 · 1 comment
Closed

v4, core 0.11: z.object() no longer extends z.core.$ZodObject #4317

RobinTail opened this issue May 4, 2025 · 1 comment

Comments

@RobinTail
Copy link
Contributor
RobinTail commented May 4, 2025
const schema = z.object({
  a: z.string(),
  b: z.number(),
  c: z.boolean(),
});

const test: z.core.$ZodObject = schema;
// ___^^^^^
TS2322: Type 'ZodObject<{ a: ZodString; b: ZodNumber; c: ZodBoolean; }, {}, {}>' is not assignable to type '$ZodObject<Readonly<Readonly<{ [k: string]: $ZodType<unknown, unknown>; }>>, Record<string, unknown>, Record<string, unknown>>'.
  Types of property '_zod' are incompatible.
    Type '$ZodObjectInternals<{ a: ZodString; b: ZodNumber; c: ZodBoolean; }, {}, {}>' is not assignable to type '$ZodObjectInternals<Readonly<Readonly<{ [k: string]: $ZodType<unknown, unknown>; }>>, Record<string, unknown>, Record<string, unknown>>'.
      Type 'Readonly<Readonly<{ [k: string]: $ZodType<unknown, unknown>; }>>' is missing the following properties from type '{ a: ZodString; b: ZodNumber; c: ZodBoolean; }': a, b, c

So that any function expecting $ZodObject argument or a generic argument extending it can no longer accept the returns of z.object() having populated shape.

caused by #4271
@colinhacks

@RobinTail RobinTail mentioned this issue May 4, 2025
@colinhacks
Copy link
Owner
colinhacks commented May 5, 2025

Fixed in 0.11.4. Thanks for catching these so fast!

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