-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
type error #2011
Comments
Having done some investigation. Issue is present in typescript 4.9.5 Removing "Writeable<>" wrapping the FilterEnum solves it for me, as the returned type from FilterEnum is already writeable. |
I think this PR introduced an issue once it's compiled to a d.ts file. The exclude method becomes this type declaration: declare class ZodEnum<T extends [string, ...string[]]> extends ZodType<T[number], ZodEnumDef<T>> {
exclude<ToExclude extends readonly [T[number], ...T[number][]]>(values: ToExclude): ZodEnum<Writeable<FilterEnum<T, ToExclude[number]>>>;
} Wrapping the output of FilterEnum in Writeable makes the typechecker not see it as matching the constraint set by ZodEnum. The wrapping of Writeable, I think, is due to the order of the createZodEnum functions overloads? I will investigate whether my assumption is correct, and potentially open a PR |
Seeing the same error with:
This error does not appear with the previous version of This same error appears for |
Fixed in Zod 3.20.5 |
in type.d.ts file, Some type errors occur here: Writeable<FilterEnum<T, ToExclude[number]>>
version: '3.20.3'
The text was updated successfully, but these errors were encountered: