From dd0962ac28ec1eee14337e5a939f8c8aee8f2998 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 23 May 2025 08:10:52 +0000 Subject: [PATCH] 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.