type UrlCellRendererProps = {
prop1: string;
};
type GroupByCellRendererProps = {
prop2: boolean;
prop3: number;
};
type TEST = UrlCellRendererProps | (UrlCellRendererProps & GroupByCellRendererProps)
// this is valid
const a: TEST = {
prop1: 'url',
}
// this is valid
const b: TEST = {
prop1: 'url',
prop2: true,
prop3: 13
}
// this should be invalid because prop3 is missing
const c: TEST = {
prop1: 'url',
prop2: true,
}
console.log(a)
in the example above I have a create a type called TEST
which is a union type of two types. How can I enforce the type so that either (prop1
is required) OR (prop1
AND prop2
AND prop3
are required)