Sometimes you want to have compile safety for your
React component that can have either properties of
type X
or of type Y
but not both.
Intuitively I would have thought that you can use union types for that such as
but it turns out this is not the case.
The correct solution to this problem is
So when we now use this component with both props, we get an error
The valid variations are <MyComp text1="foo" />
or <MyComp text2="foo" />
but not both.