mirror of
https://github.com/vercel/commerce.git
synced 2025-06-15 03:41:21 +00:00
Fix: Ensure dummy getCollectionProducts safely handles empty generic product list
Resolves a TypeScript type error in `lib/shopify/index.ts` within the dummy data logic for the `getCollectionProducts` function: "Type 'Product | undefined' is not assignable to type 'Product'." The error occurred when attempting to use `genericProducts[0]` without first ensuring that the `genericProducts` array (fetched from a dummy `getProducts({query: "generic"})` call) was not empty. The logic has been updated to check if `genericProducts.length > 0` before accessing `genericProducts[0]`. If the array is empty, `dummyCollectionProductsList` is set to an empty array, preventing the assignment of `undefined` to a variable typed as `Product[]`.
This commit is contained in:
parent
1388b81d0e
commit
128daa3f8b