Open wclr opened 3 years ago
addDefaultField
doesn't operate on codecs for object/records (they work on the basic "any" Json
type) so we can't do that with them in their current form. Adding a version that does use typing to better deal with this (and for the other field
-related migrations) seems like a reasonable idea for sure though.
The reason for not making it just record/object typed is that these field migrations can also be used in situations where the resulting type is a variant or sum type, so requiring a record/object in the middle there can make things harder to deal with.
To add missign prop we use:
But "someProp" may not exist on the record type and it is not type-checked. Would it be possible (and better) to have typed-checked property names (using Proxy) and in thouse migration helpers? Or there is a reason why not typed string props used?