8000 v4: Type signature of enum input is not properly inferred · Issue #4278 · colinhacks/zod · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

v4: Type signature of enum input is not properly inferred #4278

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
pattobrien opened this issue Apr 24, 2025 · 1 comment
Closed

v4: Type signature of enum input is not properly inferred #4278

pattobrien opened this issue Apr 24, 2025 · 1 comment

Comments

@pattobrien
Copy link

Description

Given the below code:

const myEnum = z.enum(["left", "right", "center", "justify"]);
const myObject = z.object({ myEnum: myEnum });

type MyObject = z.infer<typeof myObject>;
type MyObjectInput = z.input<typeof myObject>;

I would expect MyObjectInput to be of type:

type MyObjectInput = {
    myEnum: "left" | "right" | "center" | "justify";
}

Actual Result

The inferred type signature of MyObjectInput is shown as:

type MyObjectInput = {
    myEnum: z.core.$InferEnumInput<{
        left: "left";
        right: "right";
        center: "center";
        justify: "justify";
    }>;
}

NOTE: This is only an issue with MyObjectInput, not MyObject (i.e. output type).

@colinhacks
Copy link
Owner

Fixed in latest beta, go head any upgrade 👍


PS: Note that you'll need to rewrite your v4 imports to "zod/v4" after upgrading; for more information, see #4371 for details

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