Given these interfaces
interface TypeA {
data: { a: string; };
value: string;
age: number;
}
interface TypeB {
data: { b: number; };
value: number;
isGood: boolean;
};
How can I automatically generate this type?
All props in TypeB replace the props in TypeA
Combined {
data: { b: number; }
value: number;
age: number;
isGood: boolean;
}
I can do it manually with this:
type Combined1 = Omit<TypeA, 'data' | 'value'> & TypeB;
But I'm unsure how to do it automatically?
I've noticed that I can Omit all of the keys from TypeB from TypeA without an error.
ie: isGood isn't present in TypeA, but omitting it doesn't cause an issue. Is that helpful?
type Combined1 = Omit<TypeA, 'data' | 'value' | 'isGood'> & TypeB;