Open ForbesLindesay opened 4 years ago
There is some existing discussion of approaches in https://github.com/pelotom/runtypes/pull/113
I think given how most programs treat undefined
/optional properties, we could probably just add .Optional()
as an alias for .Or(Undefined)
Alternatively we could follow the approach in https://github.com/pelotom/runtypes/pull/131 of creating a special type to represent the "Maybe" fields.
This was implemented a few days ago in https://github.com/pelotom/runtypes/pull/113, any chance of porting that update forward?
Currently you can create an object with optional properties by using an Intersection of a
Record
and aPartial
. This has a number of issues though:Mitigation:
You can use
.Or(Undefined)
to create almost the same effect. Maybe this is good enough?Requested in: https://github.com/pelotom/runtypes/issues/136