From 8b422f231f0f30efbfc498449b5c2ded1c3c77bf Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Mon, 1 Jan 2024 17:13:47 -0800
Subject: chore(schedule): fix types

---
 src/lib/Tools/Schedule/Crunchyroll.svelte | 34 ++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 10 deletions(-)

(limited to 'src/lib/Tools/Schedule/Crunchyroll.svelte')

diff --git a/src/lib/Tools/Schedule/Crunchyroll.svelte b/src/lib/Tools/Schedule/Crunchyroll.svelte
index 19fcc9b3..efa10a2e 100644
--- a/src/lib/Tools/Schedule/Crunchyroll.svelte
+++ b/src/lib/Tools/Schedule/Crunchyroll.svelte
@@ -1,19 +1,32 @@
 <script lang="ts">
 	import crunchyroll from '$lib/crunchyroll.json';
-	import { onMount } from 'svelte';
 
-	const days = crunchyroll
+	interface CrunchyrollMedia<T = number | 'soon' | 'continuing'> {
+		year: number;
+		month: number;
+		day: T;
+		title: string;
+	}
+
+	type KnownMedia = { [key: string]: CrunchyrollMedia<number>[] };
+
+	const days: KnownMedia = crunchyroll
 		.filter((media) => media.day !== 'soon' && media.day !== 'continuing')
-		.reduce((acc, media) => {
-			const date = new Date(media.year, media.month - 1, media.day).toLocaleDateString();
-			if (!acc[date]) {
-				acc[date] = [];
-			}
-			acc[date].push(media);
+		.reduce((acc: KnownMedia, media) => {
+			const date = new Date(media.year, media.month - 1, media.day as number).toLocaleDateString();
+
+			if (!acc[date]) acc[date] = [];
+
+			acc[date].push(media as CrunchyrollMedia<number>);
+
 			return acc;
 		}, {});
-	const continuing = crunchyroll.filter((media) => media.day === 'continuing');
-	const soon = crunchyroll.filter((media) => media.day === 'soon');
+	const continuing: CrunchyrollMedia<number | string>[] = crunchyroll.filter(
+		(media) => media.day === 'continuing'
+	);
+	const soon: CrunchyrollMedia<number | string>[] = crunchyroll.filter(
+		(media) => media.day === 'soon'
+	);
 
 	const ordinalSuffix = (i: number) => {
 		const j = i % 10;
@@ -30,6 +43,7 @@
 <ol>
 	{#each Object.values(days) as day}
 		{@const date = new Date(day[0].year, day[0].month - 1, day[0].day)}
+
 		<p>
 			<li>
 				{date.toLocaleString('default', { month: 'long' })}
-- 
cgit v1.2.3

