Skip to content

Typescript errors after upgrading Zod to V4. #2820

@MichaelHindley

Description

@MichaelHindley

Description

After upgrading Zod dependency to 4.0.5 from 3 and using Express Zod API 24.6, The input and output types from the default endpoint factory seem to have a type mismatch with anything from Zod.

Before the ugprade, I was using zod/v4 from the latest 3 package.

Input/output seem to be expecting a "example" and a "deprecated" property on everything that's passed to input schema but these properties don't seem to exist on the schemas defined in Zod.

Type 'ZodObject<{ name: ZodOptional<ZodString>; }, $strip>' is missing the following properties from type 'ZodType<Base$1, unknown, $ZodTypeInternals<Base$1, unknown>>': example, deprecatedts(2739)
index.d.ts(612, 5): The expected type comes from property 'input' which is declared here on type 'BuildProps<IOSchema, IOSchema, undefined, Record<string, never>, string>'
⌘+click to open in new tab
(property) BuildProps<IOSchema, IOSchema, undefined, Record<string, never>, string>.input?: IOSchema | undefined
@desc — Input schema of the Endpoint, combining properties from all the enabled input sources (path params, headers)

This happens even with a schema defined inline, in this example I removed the schema defined in the "shared" package where all our schemas across the stack recide:

Image

Reproduction

See screenshot, this exact code was working with zod 3 and import from zod/v4.

Context

  • Node.js version: #.#.#
  • express-zod-api version:24.6
  • zod 4.0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions