Typescript Interface – Possible to make “one or the other” properties required?
If you’re truly after “one property or the other” and not both you can use never in the extending type: interface MessageBasics { timestamp?: number; /* more general properties here */ } interface MessageWithText extends MessageBasics { text: string; attachment?: never; } interface MessageWithAttachment extends MessageBasics { text?: never; attachment: string; } type Message = … Read more