I have a data structure where one of the keys allows for a dynamic set of values. I know the potential type of these values but I am unable to express this in Typescript.
It is true that a union is inclusive, so A | B
includes anything which is a valid A
, and anything which is a valid B
, including anything which is a valid A & B
. TypeScript doesn't have negated types, so you can't say something like (A | B) & !(A & B)
, which would explicitly rule out anything which matches both A
and B
.