mirror of
https://github.com/vercel/commerce.git
synced 2025-06-06 08:16:59 +00:00
Fix: Ensure getCollectionProducts safely handles undefined genericProduct[0]
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]` to populate `dummyCollectionProductsList` without definitively confirming that `genericProducts[0]` was not `undefined` (i.e., when the `genericProducts` array was empty). The logic in the fallback case for dummy data in `getCollectionProducts` has been confirmed/updated to explicitly check `genericProducts.length > 0` before accessing `genericProducts[0]`. If the `genericProducts` array is empty, `dummyCollectionProductsList` is correctly assigned an empty array, preventing the type error.
This commit is contained in:
parent
128daa3f8b
commit
1e1eeb3b37