I'd like to have a type that says:
If there's property container
present, also expect property a
. If there's item
property present, also expect property b
. container
and item
cannot exist both at the same time.
The code I'd assume would look as follows, but it doesn't seem to do the above.
type A = { container: true; a: string } | { item: true; b: number };
How do I build such a type?
null | string
seems to mean null OR string
, but SomeObject | AnotherObject
seems to mean all properties present BOTH in SomeObject and AnotherObject
.