-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
z.object is type widening to z.ZodObject<util.Writeable<T>, core.$strip> #5810
Copy link
Copy link
Open
Description
Given the following code
import { z } from "zod";
export const schema = z.object({
id: z.string(),
title: z.string(),
author: z.string(),
publishYear: z.number().nullable(),
isbn: z.string().nullable(),
description: z.string().nullable(),
source: z.enum(["OpenLibrary", "Wikidata"]),
});On this version of zod 4.3.6 , the language server in in vscode & cursor on windows 10 is type widening to:
const schema: z.ZodObject<util.Writeable<T>, core.$strip>While on zod@4.3.5 it shows the following correct type.
const schema: z.ZodObject<{
id: z.ZodString;
title: z.ZodString;
author: z.ZodString;
publishYear: z.ZodNullable<z.ZodNumber>;
isbn: z.ZodNullable<z.ZodString>;
description: z.ZodNullable<z.ZodString>;
source: z.ZodEnum<{
OpenLibrary: "OpenLibrary";
Wikidata: "Wikidata";
}>;
}, z.core.$strip>Note, I tried to replicate it in CodeSandbox but I couldn't. I've only been able to see this behavior on my dev environment.
Please let me know what I can help to reproduce this issue on your end as well.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels