Fix: Explicit undefined check for genericProducts[0] in getCollectionProducts

Resolves a persistent 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`. Previous guards like checking
`genericProducts.length > 0` were insufficient in the Vercel build
environment's TypeScript context.

This commit implements a more explicit check:
1. `genericProducts[0]` is assigned to `firstProduct` (typed Product | undefined).
2. `firstProduct` is then checked for `!== undefined` before being used.
3. If `firstProduct` is not undefined, it's safely used to create the
   `dummyCollectionProductsList`. Otherwise, an empty array is assigned.

This more explicit narrowing of the type should satisfy TypeScript's
strict checks in all environments.
This commit is contained in:
google-labs-jules[bot] 2025-05-23 08:10:52 +00:00
parent 1e1eeb3b37
commit dd0962ac28

Diff Content Not Available