diff --git a/src/lib/githubYearInReview.ts b/src/lib/githubYearInReview.ts index bb1a817..83f47a3 100644 --- a/src/lib/githubYearInReview.ts +++ b/src/lib/githubYearInReview.ts @@ -196,12 +196,12 @@ async function fetchCommitDatesForTopRepos( const dates: string[] = []; for (let i = 0; i < candidates.length; i++) { - const repoData = response[`repo${i}`] as Record | undefined; - const defaultBranchRef = repoData?.defaultBranchRef as Record | undefined; - const target = defaultBranchRef?.target as Record | undefined; - const history = target?.history as Record | undefined; - const historyNodes = (history?.nodes as Array> | undefined) || []; - for (const node of historyNodes) { + // @ts-expect-error Optional chaining through unknown type for performance + const historyNodes = response[`repo${i}`]?.defaultBranchRef?.target?.history?.nodes as Array> | undefined; + if (!historyNodes) continue; + + for (let j = 0; j < historyNodes.length; j++) { + const node = historyNodes[j]; const author = node?.author as Record | undefined; if (typeof author?.date === 'string') { dates.push(author.date);