Discriminated union with union type discriminator gives wrong error messages
Let's say I have this type, right here:
This will produce the error message
Now interestingly this only occurs because when more then ONE of the discriminators is a union. This type here will produce the correct error message
The why becomes apparent when we take a look at the precompilation, in case 2 it can just switch case over the options
where in case 1 it uses the
Is this a bug? Is there some part of set theory that can justify this behaviour that i do not yet understand?
This will produce the error message
a must be a string (was missing), b must be a string (was missing) or c must be a string (was missing), however what one would expect is a must be a string (was missing) Now interestingly this only occurs because when more then ONE of the discriminators is a union. This type here will produce the correct error message
a must be a string (was missing) The why becomes apparent when we take a look at the precompilation, in case 2 it can just switch case over the options
where in case 1 it uses the
intersectionAllows which cannot tell, that when option = "A" the only remaining field to validate will be a because it checks the WHOLE data instead of just looking at the option and then "locking" in. Is this a bug? Is there some part of set theory that can justify this behaviour that i do not yet understand?