From b907b9fb1a1a792b9bc25112fa3eb3f8d2fb4397 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 1 Oct 2025 06:43:41 +0200 Subject: [PATCH] Enable a few more tsconfig options (#35553) Enable a few more useful options in tsconfig. `noImplicitReturns` had two cases which I've fixed. Also, partially sort the file. --- tsconfig.json | 24 ++++++++++++++---------- web_src/js/features/tablesort.ts | 2 +- web_src/js/modules/toast.ts | 10 +++++----- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 0a9e080a51..3bc6065647 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "include": [ - "${configDir}/.*", "${configDir}/*", + "${configDir}/.*", "${configDir}/tests/e2e/**/*", "${configDir}/tests/e2e/**/.*", "${configDir}/tools/**/*", @@ -17,27 +17,31 @@ "allowImportingTsExtensions": true, "allowJs": true, "allowSyntheticDefaultImports": true, + "allowUnreachableCode": false, + "allowUnusedLabels": false, "alwaysStrict": true, "erasableSyntaxOnly": true, "esModuleInterop": true, + "exactOptionalPropertyTypes": false, "isolatedModules": true, "libReplacement": false, "noEmit": true, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noPropertyAccessFromIndexSignature": false, + "noUnusedLocals": true, + "noUnusedParameters": true, "resolveJsonModule": true, "skipLibCheck": true, - "verbatimModuleSyntax": true, - "stripInternal": true, + "sourceMap": true, "strict": false, "strictBindCallApply": true, "strictBuiltinIteratorReturn": true, "strictFunctionTypes": true, - "noImplicitAny": true, - "noImplicitThis": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noPropertyAccessFromIndexSignature": false, - "exactOptionalPropertyTypes": false, - "sourceMap": true, + "stripInternal": true, + "verbatimModuleSyntax": true, "types": [ "vitest/globals", "./web_src/js/globals.d.ts", diff --git a/web_src/js/features/tablesort.ts b/web_src/js/features/tablesort.ts index 0648ffd067..cd77eb971c 100644 --- a/web_src/js/features/tablesort.ts +++ b/web_src/js/features/tablesort.ts @@ -10,7 +10,7 @@ export function initTableSort() { } function tableSort(normSort: string, revSort: string, isDefault: string) { - if (!normSort) return false; + if (!normSort) return; if (!revSort) revSort = ''; const url = new URL(window.location.href); diff --git a/web_src/js/modules/toast.ts b/web_src/js/modules/toast.ts index 71a7fab8b2..395f31bc82 100644 --- a/web_src/js/modules/toast.ts +++ b/web_src/js/modules/toast.ts @@ -43,7 +43,7 @@ type ToastOpts = { type ToastifyElement = HTMLElement & {_giteaToastifyInstance?: Toast}; /** See https://github.com/apvarun/toastify-js#api for options */ -function showToast(message: string, level: Intent, {gravity, position, duration, useHtmlBody, preventDuplicates = true, ...other}: ToastOpts = {}): Toast { +function showToast(message: string, level: Intent, {gravity, position, duration, useHtmlBody, preventDuplicates = true, ...other}: ToastOpts = {}): Toast | null { const body = useHtmlBody ? message : htmlEscape(message); const parent = document.querySelector('.ui.dimmer.active') ?? document.body; const duplicateKey = preventDuplicates ? (preventDuplicates === true ? `${level}-${body}` : preventDuplicates) : ''; @@ -56,7 +56,7 @@ function showToast(message: string, level: Intent, {gravity, position, duration, showElem(toastDupNumEl); toastDupNumEl.textContent = String(Number(toastDupNumEl.textContent) + 1); animateOnce(toastDupNumEl, 'pulse-1p5-200'); - return; + return null; } } @@ -83,15 +83,15 @@ function showToast(message: string, level: Intent, {gravity, position, duration, return toast; } -export function showInfoToast(message: string, opts?: ToastOpts): Toast { +export function showInfoToast(message: string, opts?: ToastOpts): Toast | null { return showToast(message, 'info', opts); } -export function showWarningToast(message: string, opts?: ToastOpts): Toast { +export function showWarningToast(message: string, opts?: ToastOpts): Toast | null { return showToast(message, 'warning', opts); } -export function showErrorToast(message: string, opts?: ToastOpts): Toast { +export function showErrorToast(message: string, opts?: ToastOpts): Toast | null { return showToast(message, 'error', opts); }