Skip to content

Commit

Permalink
Fixes test by checking for single value unions.
Browse files Browse the repository at this point in the history
  • Loading branch information
anglinb committed Jul 28, 2021
1 parent cb181d9 commit e1751ca
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/generateZodSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,11 @@ function buildZodPrimitive({
getDependencyName,
})
);
// type A = | 'b' is a valid typescript definintion
// Zod does not allow `z.union(['b']), so we have to return just the value
if (values.length === 1) {
return values[0];
}
return buildZodSchema(
z,
"union",
Expand Down

0 comments on commit e1751ca

Please sign in to comment.