3 ms·
Does/will this correctly handle `| undefined` vs `?`, i.e. correct behavior under `exactOptionalPropertyTypes`? Zod doesn't (yet[0]) and it's been a pain point
by kaoD 2y ago
Does/will this correctly handle `| undefined` vs `?`, i.e. correct behavior under `exactOptionalPropertyTypes`?
Zod doesn't (yet[0]) and it's been a pain point for me.
[0] https://github.com/colinhacks/zod/issues/635 https://github.com/colinhacks/zod/issues/635
- x1000 2y agoI ran into exactly same pain point which was enough to nullify the benefits of using zod at all.
- aleclarsoniv 2y agoTypeBox[1] differentiates between optional and undefined. [1]: https://github.com/sinclairzx81/typebox https://github.com/sinclairzx81/typebox
- gkiely 2y agoIt does: https://valibot.dev/guides/optionals/#use-in-objects https://valibot.dev/guides/optionals/#use-in-objects import * as v from 'valibot'; const OptionalKeySchema = v.object({ key: v.optional(v.string()) }); type t1 = v.InferInput<typeof OptionalKeySchema>; // { key?: string } const UndefinedKeySchema = v.object({ key: v.undefinedable(v.string()) }); type t2 = v.InferInput<typeof UndefinedKeySchema>; // { key: undefined }