Having a TypeScript interface defined as follows:
interface SampleShape {
prop1?: string;
prop2?: string;
}
Additionally, I have another separate interface in mind to utilize:
interface Payload {
model: {
name?: string;
prop1?: string; // same as the one in SampleShape
prop2?: string; // same as the one in SampleShape
}
}
The scenario involves transforming an object of SampleShape into a new Payload object. Is there a method to dynamically extract the types from SampleShape
to avoid redundancy?