You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But when I assign a Product object, it recognizes as Vehicle and throw type error.
constproduct: MyProduct={"schema": {"offers": [{"seller": {"name": "XYZ","@type": "Organization"},"priceCurrency": "INR","availability": "http://schema.org/InStock","@type": "Offer","url": "https://www.xyz.com/en_in/productpage.0874876001.html","price": "1499.0"}],"image": "//www.xyz.com/image.jpg","color": "Pigeon blue/Floral","@type": "Product","name": "Fitted cotton sheet","description": "Fitted sheet with an all-over print on fine-threaded, closely-woven cotton with a thread count of 144. Fits mattresses up to 23 cm deep.","sku": "1234567","category": {"name": "Sheets","@type": "Thing"},"@context": "https://schema.org","brand": {"name": "XYZ","@type": "Brand"},"itemCondition": "https://schema.org/NewCondition"},"image": "//www.xyz.com/image.jpg","meta": {"parser": "schema","modifiedDate": "2022-09-14T14:09:18.639Z","createdDate": "2022-09-14T14:09:18.639Z"},"name": "Fitted cotton sheet","description": "Fitted sheet with an all-over print on fine-threaded, closely-woven cotton with a thread count of 144. Fits mattresses up to 23 cm deep.","sku": "0874876001","url": "https://www.xyz.com/en_in/productpage.0874876001.html"}
Error:
Type '"Product"' is not assignable to type '"MotorizedBicycle"'.ts(2322)
Any help or guidance would be appreciated. Thanks
The text was updated successfully, but these errors were encountered:
The error is misleading, because type matching is weird, but if you look at the editor you'll see a few errors at a few degrees of nesting:
Top Level: 'Your Product Type is wrong' (bad message, it tries to match Product against every product, and fails. Says your product doesn't match a random type. MotorizedBicycle is a type of product. But the real message is that your type doesn't match _any)
One Level down, you'll see that the offers array is also complaining. "Your offer is wrong" (It also says offer is not a valid offer for purchase)
One level down, you'll notice that availability is wrong. You have http://schema.org/InStock, but we expect https.
I defined a wrapper class to store data, like
But when I assign a
Product
object, it recognizes asVehicle
and throw type error.Error:
Type '"Product"' is not assignable to type '"MotorizedBicycle"'.ts(2322)
Any help or guidance would be appreciated. Thanks
The text was updated successfully, but these errors were encountered: