|
|
|
|
|
by Ezku
2283 days ago
|
|
You mention creating object types with optional keys is cumbersome in io-ts. How is that solved in zod, exactly? What allows you to map `foo: union([bar, undefined])` to `foo?: bar | undefined` (note the question mark on the left hand side)? There’s nothing in the declaration to give away why this wouldn’t yield `foo: bar | undefined` which is what I believe you’d get out of io-ts. Looks useful - I would have an easier time introducing this than io-ts. |
|
Here's the Zod equivalent:
And here's the code that pulls this off: