I have got error
Property 'pricePerItem' does not exist on type 'ShipProductDetail'.
(the type of product is ProductDetail | ShipProductDetail)
but I've used sort of Type Guards
<span
*ngIf="product.hasOwnProperty('pricePerItem')"
class="text-uppercase smaller"
>
{{ product.pricePerItem.priceWithVat | i18nNumber | ogCurrency }}
</span>
Is it a bug or not?
UPDATE
It's not a bug its my fault :)
I worked it out with
hasPricePerItem(
product: ProductDetail | ShipProductDetail
): PriceAndVatModel | null {
if ((product as ProductDetail).pricePerItem) {
return (product as ProductDetail).pricePerItem;
}
return null;
}
<span *ngIf="hasPricePerItem(product)" class="text-uppercase smaller">
{{ hasPricePerItem(product)?.priceWithVat | i18nNumber | ogCurrency }}
</span>