Here is the object I am working with:
interface Cart {
orderPromo?: ProductPromotion[],
productPromo?: ProductPromotion[],
}
Both properties are of the same type, but they can be undefined. What is the most efficient and clean way to merge them?
I initially attempted the following:
const promotions: ProductPromotion[] = [...cart.orderPromo, ...cart.productPromo];
However, this code resulted in an error message:
TS2488: Type 'ProductPromotion[] | undefined' must have a '[Symbol.iterator]()' method that returns an iterator.