You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Typescript allows for single values unions like this. It simply collapses the union so to typescript this value is really just type A = B. ts-to-zod produces a union of a single element which zod does not allow, so validation fails.
type A =
| B
Input
typeA=|B
Expected output
exportconstaSchema=z.literal("b");
Actual output
exportconstaSchema=z.union([z.literal("b")]);
Versions
Typescript: v4.2.3
Zod: v3.1.0
The text was updated successfully, but these errors were encountered:
Bug description
Typescript allows for single values unions like this. It simply collapses the union so to typescript this value is really just
type A = B
.ts-to-zod
produces a union of a single element whichzod
does not allow, so validation fails.Input
Expected output
Actual output
Versions
v4.2.3
v3.1.0
The text was updated successfully, but these errors were encountered: