From 306fd8e26c268fd6dd68066f3535b1a383126fcf Mon Sep 17 00:00:00 2001 From: Bram Suurd <78373894+BramSuurdje@users.noreply.github.com> Date: Wed, 6 Nov 2024 23:25:30 +0100 Subject: [PATCH] Refactor MostViewedScripts to ensure proper type annotations and improve array concatenation method for better readability --- frontend/src/app/scripts/_components/ScriptInfoBlocks.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/scripts/_components/ScriptInfoBlocks.tsx b/frontend/src/app/scripts/_components/ScriptInfoBlocks.tsx index fd1b8df5..34bf4427 100644 --- a/frontend/src/app/scripts/_components/ScriptInfoBlocks.tsx +++ b/frontend/src/app/scripts/_components/ScriptInfoBlocks.tsx @@ -136,13 +136,12 @@ export function LatestScripts({ items }: { items: Category[] }) { } export function MostViewedScripts({ items }: { items: Category[] }) { - const mostViewedScripts = items.reduce((acc, category) => { + const mostViewedScripts = items.reduce((acc: Script[], category) => { const foundScripts = category.scripts.filter((script) => mostPopularScripts.includes(script.name), ); - acc.push(...foundScripts); - return acc; - }, [] as Script[]); + return acc.concat(foundScripts); + }, []); return (