From f0ce72898268838138ce74b05c10042cd09cddf8 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 14 Jun 2025 16:40:50 +0300 Subject: [PATCH] refactor(website): improve types --- apps/website/src/lib/download-helper.ts | 12 +++++++++++- apps/website/src/routes/download/+page.svelte | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/website/src/lib/download-helper.ts b/apps/website/src/lib/download-helper.ts index f01aa15ea..0f9642876 100644 --- a/apps/website/src/lib/download-helper.ts +++ b/apps/website/src/lib/download-helper.ts @@ -1,5 +1,7 @@ import rootPackageJson from '../../../../package.json'; +type App = "desktop"; + export type Architecture = 'x64' | 'arm64'; export type Platform = 'mac' | 'windows' | 'linux'; @@ -10,8 +12,16 @@ export function buildDesktopDownloadUrl(platform: Platform, format: string, arch return `https://github.com/TriliumNext/Notes/releases/download/${version}/TriliumNextNotes-${version}-${platform}-${architecture}.${format}`; } +interface DownloadMatrixEntry { + title: Record; + description: Record; + downloads: Record; +} + +type DownloadMatrix = Record>; + // Keep compatibility info inline with https://github.com/electron/electron/blob/main/README.md#platform-support. -export const downloadMatrix = { +export const downloadMatrix: DownloadMatrix = { desktop: { windows: { title: { diff --git a/apps/website/src/routes/download/+page.svelte b/apps/website/src/routes/download/+page.svelte index b26bbb4d1..4cf09f2a8 100644 --- a/apps/website/src/routes/download/+page.svelte +++ b/apps/website/src/routes/download/+page.svelte @@ -2,7 +2,7 @@ import type { Platform } from "$lib/download-helper"; import { buildDesktopDownloadUrl, downloadMatrix, getArchitecture } from "$lib/download-helper"; - let architectures = ["x64", "arm64"]; + let architectures = ["x64", "arm64"] as const; let architecture = getArchitecture();