Is there any other way to split a combined interface object into 2 objects? I thought of these, but I would like a more automatic one.
Example:
interface Interface1 {
name: string;
age: number;
}
interface Interface2 {
address: string;
phone: number;
}
interface CombinedInterface extends Interface1, Interface2 {
}
const example: CombinedInterface = {
name: 'John Doe',
age: 30,
address: '123 Main St',
phone: 1234567890
};
To
1)
const interface1: Interface1 = {
name: example.name,
age: example.age
};
const interface2: Interface2 = {
address: example.address,
phone: example.phone
};
const { name, age } = example;
const interface1: Interface1 = { name, age };
const { address, phone } = example;
const interface2: Interface2 = { address, phone };
Looked for a more automatic way to do this 😦