From e2da7eeb2f10d643f554c07eb7d060fa55870e9d Mon Sep 17 00:00:00 2001 From: Harry Buisman Date: Sun, 14 Jul 2024 21:15:57 +1000 Subject: [PATCH] Remove any type and make removeEdgesAndNodes generic --- lib/shopify/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/shopify/index.ts b/lib/shopify/index.ts index ca5ddbdb61..a34257bcf3 100644 --- a/lib/shopify/index.ts +++ b/lib/shopify/index.ts @@ -114,7 +114,7 @@ export async function shopifyFetch({ } } -const removeEdgesAndNodes = (array: Connection) => { +const removeEdgesAndNodes = (array: Connection): T[] => { return array.edges.map((edge) => edge?.node); }; @@ -163,7 +163,7 @@ const reshapeImages = (images: Connection, productTitle: string) => { const flattened = removeEdgesAndNodes(images); return flattened.map((image) => { - const filename = image.url.match(/.*\/(.*)\..*/)[1]; + const filename = image.url.match(/.*\/(.*)\..*/)?.[1]; return { ...image, altText: image.altText || `${productTitle} - ${filename}`