Remove any type and make removeEdgesAndNodes generic (#1353)

This commit is contained in:
Harry Buisman 2024-07-15 03:20:15 +10:00 committed by GitHub
parent 7fd9ad8a8c
commit 7c1b34abdb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -114,7 +114,7 @@ export async function shopifyFetch<T>({
}
}
const removeEdgesAndNodes = (array: Connection<any>) => {
const removeEdgesAndNodes = <T>(array: Connection<T>): T[] => {
return array.edges.map((edge) => edge?.node);
};
@ -163,7 +163,7 @@ const reshapeImages = (images: Connection<Image>, 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}`