Skip to content
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

Bug: Zod function types not inferred correctly #3773

Open
GiveMe-A-Name opened this issue Sep 26, 2024 · 0 comments
Open

Bug: Zod function types not inferred correctly #3773

GiveMe-A-Name opened this issue Sep 26, 2024 · 0 comments

Comments

@GiveMe-A-Name
Copy link

Detail

Zod types generate function always carry a unknown[] args.
But it's a difference from (...args: unknown[]) => string; between () => string;

Code

import { z } from "zod";

const myFunction = z.function().returns(z.string());

// MyFunction1 type is (...args: unknown[]) => string;
type MyFunction1 = z.infer<typeof myFunction>;

const f1: MyFunction1 = (x1: string) => "";

// Expect type is () => string;
type MyFunction2 = () => string;

const f2: MyFunction2 = () => "";
@GiveMe-A-Name GiveMe-A-Name changed the title [Bug]Zod function types not inferred correctly Bug: Zod function types not inferred correctly Sep 26, 2024
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

1 participant