I have defined an interface within my software:
interface Asset {
id: string;
internal_id: string;
usage: number;
}
This interface is a component of another interface named Post:
interface Post {
asset: Asset;
}
In addition, there is an interface designed for a post draft, where the asset object can be incompletely constructed:
interface PostDraft {
asset: Asset;
}
My goal is to allow a PostDraft object to contain a partially complete asset object while still enforcing type checks on the available properties (rather than using any
).
Essentially, I am seeking a method to generate the following structure:
interface AssetDraft {
id?: string;
internal_id?: string;
usage?: number;
}
without fully redefining the original Asset interface. Is there a technique to achieve this? If not, what would be the most efficient approach to organizing my types in this scenario?