From c0e80dbe26c77453dfdc33979c9f69eb6eba18c4 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 21 Dec 2024 19:59:25 +0100 Subject: [PATCH] Enable Typescript `strictFunctionTypes` (#32911) 1. Enable [strictFunctionTypes](https://www.typescriptlang.org/tsconfig/#strictFunctionTypes) 2. Introduce `DOMEvent` helper type which sets `e.target`. Surely not totally correct with that `Partial` but seems to work. 3. Various type-related refactors, change objects in `eventsource.sharedworker.ts` to `Map`. --- tsconfig.json | 1 + web_src/js/components/ContextPopup.vue | 5 +- web_src/js/features/clipboard.ts | 3 +- web_src/js/features/colorpicker.ts | 7 +-- web_src/js/features/common-form.ts | 4 +- web_src/js/features/comp/Cropper.ts | 4 +- web_src/js/features/comp/ReactionSelector.ts | 5 +- .../js/features/eventsource.sharedworker.ts | 49 ++++++++++--------- web_src/js/features/notification.ts | 6 +-- web_src/js/features/oauth2-settings.ts | 6 ++- web_src/js/features/repo-graph.ts | 12 ++--- web_src/js/features/repo-home.ts | 4 +- web_src/js/features/repo-issue.ts | 21 ++++---- web_src/js/features/repo-release.ts | 8 +-- web_src/js/features/repo-search.ts | 4 +- web_src/js/features/repo-settings.ts | 4 +- web_src/js/features/repo-wiki.ts | 2 +- web_src/js/htmx.ts | 4 +- web_src/js/markup/html2markdown.ts | 16 +++--- web_src/js/modules/tippy.ts | 10 ++-- web_src/js/utils/dom.ts | 3 +- 21 files changed, 94 insertions(+), 84 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 7d0316db29..d32cca0aaa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,6 +22,7 @@ "verbatimModuleSyntax": true, "stripInternal": true, "strict": false, + "strictFunctionTypes": true, "noUnusedLocals": true, "noUnusedParameters": true, "noPropertyAccessFromIndexSignature": false, diff --git a/web_src/js/components/ContextPopup.vue b/web_src/js/components/ContextPopup.vue index b0e8447302..0aae202d42 100644 --- a/web_src/js/components/ContextPopup.vue +++ b/web_src/js/components/ContextPopup.vue @@ -25,10 +25,9 @@ const body = computed(() => { const root = ref(null); onMounted(() => { - root.value.addEventListener('ce-load-context-popup', (e: CustomEvent) => { - const data: IssuePathInfo = e.detail; + root.value.addEventListener('ce-load-context-popup', (e: CustomEventInit) => { if (!loading.value && issue.value === null) { - load(data); + load(e.detail); } }); }); diff --git a/web_src/js/features/clipboard.ts b/web_src/js/features/clipboard.ts index 8f40f34f74..22c264d774 100644 --- a/web_src/js/features/clipboard.ts +++ b/web_src/js/features/clipboard.ts @@ -1,6 +1,7 @@ import {showTemporaryTooltip} from '../modules/tippy.ts'; import {toAbsoluteUrl} from '../utils.ts'; import {clippie} from 'clippie'; +import type {DOMEvent} from '../utils/dom.ts'; const {copy_success, copy_error} = window.config.i18n; @@ -9,7 +10,7 @@ const {copy_success, copy_error} = window.config.i18n; // - data-clipboard-target: Holds a selector for a or