Solución
solution.tsTypeScript
interface Entity {
id: number;
createdAt: Date;
}
interface Product extends Entity {
// Hacé que Product extienda Entity y agrega name y price
name: string;
price: number;
}
interface PhysicalProduct extends Product {
// Hacé que PhysicalProduct extienda Product y agrega weightKg y stock
weightKg: number;
stock: number;
}
export function getPhysicalProduct(): PhysicalProduct {
// Retorná un objeto que cumpla la interfaz completa
// return {"id":1, 'createdAt': new Date(), "name":"Mochila","price":49.99,"weightKg":0.8,"stock":20};
return {"id":1, "name":"Mochila","price":49.99,"weightKg":0.8,"stock":20} as PhysicalProduct;
}0respuestas