I'd like to define an interface that allows you to supply content
OR content_object
but not both. You have to define one or the other. What is the simplest way to achieve this in TypeScript? I know I could say that content is string | object
, but the rest of my code benefits if I can define it as described instead.
interface IModal {
content?: string;
content_object?: object;
}
type IModal = { content: string; content_object?: undefined } |
{ content_object: object; content?: undefined }
This answer contains only code and is therefore bad according to automated systems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With