constructor(recipeDetails: { title?: string, description?: string } = { title: "", description: "" }) {
for (let key in recipeDetails) {
this[key.toString()] = recipeDetails[key];
}
}
constructor(recipeDetails: Details = { title: "", description: "", ingredients: [] }) {
for (let key in recipeDetails) {
(this[key as keyof Details] as Details[keyof Details]) = recipeDetails[key as keyof Details];
}
}
interface Details { title?: string, description?: string, ingredients?: RecipeIngredient[]}