No longer possible to coerce values to `undefined`
benj-dobs opened this issue · comments
benj-dobs commented
If I return undefined
from a coercion, the coercion is ignored completely, and the original value is kept (even if the original value does not satisfy the struct we're coercing the value into).
The most common use case in my project is:
const coercableOptional = <T>(struct: Struct<T>) =>
coerce(optional(struct), literal(null), () => undefined);
This no longer works: null
values are retained, even if struct
should not allow null values.
I think this was caused by #1106
Is there an alternative syntax for coercing to undefined, or is this a bug that needs fixing?
benj-dobs commented
I'm more and more convinced this is a bug, and I've raised a pull request to fix it. Let me know if I've got that wrong :)