Skip to content

z.object is type widening to z.ZodObject<util.Writeable<T>, core.$strip> #5810

@eyueldk

Description

@eyueldk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions