adding onUndeclaredKey crashes everything :(
1 Reply
So this is basically saying that since your two types are overlapping and
delete is a transformation, it isn't possible to apply it deterministically.
In this case we know that the transformation would never affect the branches differently since they have the same properties, but the logic to know that transformation is safe isn't built into ArkType yet.
If the type only allowed one prop or the other, e.g. if you had content?: never and components?: never in the opposite branches, it would be fine
Assuming you also want to allow both properties to be specified, the best option might be to use a narrow to check that one of content or components was defined and avoid the union altogether
It may be possible for ArkType to determine the transforms are equivalent because the keys are equivalent but off the top of my head I couldn't tell you whether that would be trivial or require a big refactor... maybe worth looking into if you'd be open to contributing though? I think we already have some kind of logic to cache transformation logic from delete
Not sure exactly why it doesn't trigger here