Open andrewconner opened 4 years ago
I'm also looking in this issue.
@andrewconner Have you been able to find a workaround for that?
I'm also looking in this issue.
@andrewconner Have you been able to find a workaround for that?
No, unfortunately not. My solution was to just maintain two separate entire types in code; i.e., C
(complete) and P
(partial). To ensure they stay together, I have a "type proof" function, which is never called, that asserts that all C
's are P
's, and all P
's are RecursivePartial<C>
's (as defined above). The existence of this function proves at compile time that I didn't screw up a field somewhere.
Consider this definition of
RecursivePartial
:Is there a way to model this in io-ts? I have a large, nested record which is built incrementally over time. I'd like to model the "complete" type in io-ts, but be able to validate the recursive Partial (i.e., any key can be missing, and any provided key which is a record can have missing keys, etc).
Thanks!