The parsed data-product value to test
True when value is an object usable as a LeroChem data-product
const parsed: unknown = JSON.parse(el.getAttribute("data-product") ?? "null");
if (isLeroChemDataProduct(parsed)) {
console.log(parsed.price_amount);
}
export function isLeroChemDataProduct(value: unknown): value is LeroChemDataProduct {
return isPopulatedObject(value);
}
Type guard for the
#product-detailsdata-productdataset (a PrestaShop product combination). Narrows an unknown parsed value to LeroChemDataProduct; only requires that it be a populated object, as every field is optional.