This is the idiomatic usage pattern for optional(custom(...)).
optional only affects serialization so we must make sure to check
if the value is undefined or not, if yes, serialize, else, return undefined
which will be processed by optional(...) as SKIP.
This is the idiomatic usage pattern for
optional(custom(...))
.optional
only affects serialization so we must make sure to check if the value isundefined
or not, if yes, serialize, else, returnundefined
which will be processed byoptional(...)
asSKIP
.optional
does not affect deserialization, however, asundefined
values are automatically skipped See https://github.com/mobxjs/serializr/issues/73#issuecomment-535641545