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:
google-labs-jules[bot] 2025-05-23 07:56:43 +00:00
parent 128daa3f8b
commit 1e1eeb3b37

Diff Content Not Available