From eda93450757253612bdb406ed7a235b39ab08548 Mon Sep 17 00:00:00 2001 From: Shinsina Date: Wed, 8 May 2024 13:00:01 -0500 Subject: [PATCH 1/3] Include @types/alpinejs__collapse in dependencies --- package-lock.json | 9 +++++++++ package.json | 1 + 2 files changed, 10 insertions(+) diff --git a/package-lock.json b/package-lock.json index 299b869..a9c40e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@astrojs/sitemap": "^3.1.4", "@astrojs/tailwind": "^5.1.0", "@types/alpinejs": "^3.13.10", + "@types/alpinejs__collapse": "^3.13.4", "alpinejs": "^3.13.10", "astro": "4.5.8", "tailwindcss": "^3.4.3" @@ -1273,6 +1274,14 @@ "resolved": "https://registry.npmjs.org/@types/alpinejs/-/alpinejs-3.13.10.tgz", "integrity": "sha512-ah53tF6mWuuwerpDE7EHwbZErNDJQlsLISPqJhYj2RZ9nuTYbRknSkqebUd3igkhLIZKkPa7IiXjSn9qsU9O2w==" }, + "node_modules/@types/alpinejs__collapse": { + "version": "3.13.4", + "resolved": "https://registry.npmjs.org/@types/alpinejs__collapse/-/alpinejs__collapse-3.13.4.tgz", + "integrity": "sha512-kUBJWEDrHahD2Tb1lrir7iNTGN9ukvoJFjOY41EGC7F21E1KMSch5NrGgE0sqINrRT3lf1UZm3wxB3CNjJHBwg==", + "dependencies": { + "@types/alpinejs": "*" + } + }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", diff --git a/package.json b/package.json index 65863dc..849aa8e 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "@astrojs/sitemap": "^3.1.4", "@astrojs/tailwind": "^5.1.0", "@types/alpinejs": "^3.13.10", + "@types/alpinejs__collapse": "^3.13.4", "alpinejs": "^3.13.10", "astro": "4.5.8", "tailwindcss": "^3.4.3" From 436ba38938162d09b274641b9633728b71f7033e Mon Sep 17 00:00:00 2001 From: Shinsina Date: Wed, 8 May 2024 13:01:32 -0500 Subject: [PATCH 2/3] Reconcile typing within db/seed.ts and src/lib/alpine.ts --- db/seed.ts | 32 ++++++++++++++++++-------------- src/lib/alpine.ts | 18 +++++++++++------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/db/seed.ts b/db/seed.ts index 35123ac..b6b71e0 100644 --- a/db/seed.ts +++ b/db/seed.ts @@ -76,22 +76,25 @@ export default async function seed() { await db.insert(CarClass).values(carClasses); console.log("Car Classes Seeded!"); console.log("Seeding Seasons..."); - await db.insert(Season).values( - seasons.map((season: any) => { - const { start_date, ...rest } = season; - return { - ...rest, - start_date: new Date(start_date), - }; - }) - ); + const seasonsAsArray = Array.isArray(seasons) + ? seasons.map((season: any) => { + const { start_date, ...rest } = season; + return { + ...rest, + start_date: new Date(start_date), + }; + }) + : []; + await db.insert(Season).values(seasonsAsArray); console.log("Seeded Seasons!"); console.log("Seeding Past Seasons..."); + const pastSeasonsAsObject = pastSeasons as Record; await db.insert(PastSeason).values( - Object.keys(pastSeasons) + Object.keys(pastSeasonsAsObject) .map((key) => - pastSeasons[key].series.seasons.filter((season) => - seasonIdArray.includes(season.season_id) + pastSeasonsAsObject[key].series.seasons.filter( + (season: typeof PastSeason) => + seasonIdArray.includes(Number(season.season_id)) ) ) .flat() @@ -113,16 +116,17 @@ export default async function seed() { ); console.log("Standings Seeded!"); console.log("Seeding Subsessions..."); + const subsessionsTyped = subsessions as Record; const { allPracticeResults, allQualifyingResults, allRaceResults, allSubsessions, - } = Object.keys(subsessions).reduce( + } = Object.keys(subsessionsTyped).reduce( // @todo Provide an accurate type for the unknown here (object: Record>, key) => { const { session_results, end_time, start_time, ...rest } = - subsessions[key]; + subsessionsTyped[key]; session_results.forEach((sessionResult) => { const { results, ...rest } = sessionResult; results.forEach((result) => { diff --git a/src/lib/alpine.ts b/src/lib/alpine.ts index 6deef08..3154b5f 100644 --- a/src/lib/alpine.ts +++ b/src/lib/alpine.ts @@ -1,5 +1,4 @@ import type { Alpine } from "alpinejs"; -// @ts-expect-error import collapse from "@alpinejs/collapse"; import Table from "$lib/components/table"; @@ -17,12 +16,17 @@ export default (Alpine: Alpine) => { RACE: false, toggle() { this.$el.id.split(" ").forEach((id, index) => { - if (index) { - // @ts-expect-error - this[id] = false; - } else { - // @ts-expect-error - this[id] = !this[id]; + if ( + id === "PRACTICE" || + id === "QUALIFY" || + id === "HEAT" || + id === "RACE" + ) { + if (index) { + this[id] = false; + } else { + this[id] = !this[id]; + } } }); }, From 438306835bd64df48a2b7cb343bb1f574ca75829 Mon Sep 17 00:00:00 2001 From: Shinsina Date: Wed, 8 May 2024 13:01:53 -0500 Subject: [PATCH 3/3] Reconcile typing within Season Summary pages --- .../[carClassId]/season-summary.astro | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/pages/user/[id]/season/[seasonId]/car-class/[carClassId]/season-summary.astro b/src/pages/user/[id]/season/[seasonId]/car-class/[carClassId]/season-summary.astro index 2dd5cad..e55d180 100644 --- a/src/pages/user/[id]/season/[seasonId]/car-class/[carClassId]/season-summary.astro +++ b/src/pages/user/[id]/season/[seasonId]/car-class/[carClassId]/season-summary.astro @@ -14,7 +14,12 @@ import handleResults from "$lib/utils/handle-session-results"; import fieldIdToLabelMap from "$lib/utils/field-id-to-label-map"; import lapTimeFields from "$lib/utils/lap-time-fields"; import parseLapTime from "$lib/utils/parse-lap-time"; -import type { License, SessionResult, Track } from "$lib/types"; +import type { + License, + SessionResult, + Subsession as SubsessionType, + Track, +} from "$lib/types"; import userIds from "$lib/utils/user-ids"; export async function getStaticPaths() { const seasons = await db @@ -66,7 +71,7 @@ trackSchedule.forEach((track) => { }); const resultsPerWeek: Array<{ - subsession: typeof Subsession; + subsession: SubsessionType; userResult: SessionResult; }> = []; trackScheduleMap.forEach((value) => { @@ -141,16 +146,16 @@ const results = resultsPerWeek.map((result) => { allowed_licenses.length ? (allowed_licenses.slice(0, 2).pop() as License) : ({} as License); + const subsessionAsSubsessionType = subsession as unknown as SubsessionType; const sof = { - "Strength Of Field": subsession.race_summary - ? // @ts-expect-error - subsession.race_summary.field_strength + "Strength Of Field": subsessionAsSubsessionType.race_summary + ? subsessionAsSubsessionType.race_summary.field_strength : null, }; + const trackAsTrackType = track as unknown as Track; return { subsession_id, - // @ts-expect-error - Track: `${track.track_name} ${track.config_name && track.config_name !== "N/A" ? track.config_name : ""}`, + Track: `${trackAsTrackType.track_name} ${trackAsTrackType.config_name && trackAsTrackType.config_name !== "N/A" ? trackAsTrackType.config_name : ""}`, Corners: corners_per_lap, License, license_category,