From 728ad56b33cdc64fb1a4f71deeeb8eff8e56c76a Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Tue, 1 Mar 2022 02:00:01 +0100 Subject: [PATCH] enforce strict typescript --- frontend/src/lib/files.ts | 2 +- frontend/src/lib/ui/FileUpload.svelte | 2 +- frontend/src/lib/ui/TextInput.svelte | 2 +- frontend/src/lib/views/Create.svelte | 2 +- frontend/src/routes/__layout.svelte | 2 +- frontend/src/routes/note/[id].svelte | 11 +++++++---- frontend/tsconfig.json | 3 ++- 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/frontend/src/lib/files.ts b/frontend/src/lib/files.ts index 26cf3e2..78a31d2 100644 --- a/frontend/src/lib/files.ts +++ b/frontend/src/lib/files.ts @@ -7,7 +7,7 @@ export class Files { }) } - static fromString(s: string): Promise { + static async fromString(s: string): Promise { return fetch(s).then((r) => r.blob()) } } diff --git a/frontend/src/lib/ui/FileUpload.svelte b/frontend/src/lib/ui/FileUpload.svelte index ee5b752..14b5476 100644 --- a/frontend/src/lib/ui/FileUpload.svelte +++ b/frontend/src/lib/ui/FileUpload.svelte @@ -12,7 +12,7 @@ async function onInput(e: Event) { const input = e.target as HTMLInputElement - if (input.files.length) { + if (input?.files?.length) { files = Array.from(input.files) const data: FileDTO[] = await Promise.all( files.map(async (file) => ({ diff --git a/frontend/src/lib/ui/TextInput.svelte b/frontend/src/lib/ui/TextInput.svelte index 13ff666..da8d9ee 100644 --- a/frontend/src/lib/ui/TextInput.svelte +++ b/frontend/src/lib/ui/TextInput.svelte @@ -8,7 +8,7 @@ import Icon from './Icon.svelte' export let label: string = '' - export let value: string | number + export let value: any export let copy: boolean = false export let random: boolean = false diff --git a/frontend/src/lib/views/Create.svelte b/frontend/src/lib/views/Create.svelte index 8af4c08..663dbc4 100644 --- a/frontend/src/lib/views/Create.svelte +++ b/frontend/src/lib/views/Create.svelte @@ -33,7 +33,7 @@ message = $t('home.explanation', { values: { type: $t(timeExpiration ? 'common.minutes' : 'common.views', { - values: { n: timeExpiration ? note.expiration : note.views }, + values: { n: (timeExpiration ? note.expiration : note.views) ?? '?' }, }), }, }) diff --git a/frontend/src/routes/__layout.svelte b/frontend/src/routes/__layout.svelte index e0d928c..4ea067a 100644 --- a/frontend/src/routes/__layout.svelte +++ b/frontend/src/routes/__layout.svelte @@ -3,7 +3,7 @@ // @ts-ignore import { registerAll } from '$locales' registerAll() - init({ initialLocale: getLocaleFromNavigator(), fallbackLocale: 'en' }) + init({ initialLocale: getLocaleFromNavigator() ?? undefined, fallbackLocale: 'en' })