Struggling with a Typescript concept. In my application users can create bids or prices for products available for sale, but when doing the typing I keep going back and forth between making parameters optional so that I can pass in a partially created model to be saved and have data filled in like id, created_date, etc. and just use the same model for the return type.
It feels redundant to make multiple interfaces for what is ultimately the same model, but based on my reading I'm just thinking of this wrong and should be looking at the form data and created model separately. Just wondering if this is the accepted practice amongst people that use Typescript all the time?
interface Price {
id?:number;
amount: number;
product: Product | number;
created_on?: string;
}
vs
interface PriceFormData {
amount: number;
product: number;
}
interface Price {
id: number;
amount: number;
product: Product;
created_on: string;
}