swellstores / swell-js

JS library for building storefronts and checkouts with Swell ecommerce.
https://swell.is
MIT License
138 stars 29 forks source link

Swell v4.0.7+: Cart & Product Typescript inconsistencies #175

Closed fourwordsnz closed 4 months ago

fourwordsnz commented 4 months ago

I updated to Swell's latest version (4.0.9) but ran into TypeScript inconsistencies with docs and response.

Issue 1 – Attributes Values Key for Products & Product Variants

I'm having response generated via swell.products.variation() or via swell.products.get(slug)

Example:

Screenshot 2024-04-24 at 7 31 59 PM

Issue 2 – addItem: CartItem

Using swell.cart.addItem(product) and sending an object with keys below:

{ product_id, quantity, variant_id, metadata }

With the update, now getting a type error, not assignable to CartItem. It now expects id to be included.

Per docs, the object is what should be sent. Functionality wise there are no issues. Just a type issue. I can ignore it.

But is this expected or something on my end?

awwit commented 4 months ago

@fourwordsnz good catch! We have released v4.1.0 with a fix.