diff options
author | silverwind <me@silverwind.io> | 2024-12-11 09:29:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-11 09:29:04 +0100 |
commit | 8a53a39c426e95164e87a3b0857eb420711bfd85 (patch) | |
tree | fc67b0cbf041fa56fec81d9bb862e154e2e6f079 /web_src/js/modules | |
parent | e619384098419569e570796a57ee6af4948067ae (diff) | |
download | gitea-8a53a39c426e95164e87a3b0857eb420711bfd85.tar.gz gitea-8a53a39c426e95164e87a3b0857eb420711bfd85.zip |
Fix a number of typescript errors (#32773)
Fixes 96 typescript errors. Behaviour changes are commented below.
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'web_src/js/modules')
-rw-r--r-- | web_src/js/modules/toast.ts | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/web_src/js/modules/toast.ts b/web_src/js/modules/toast.ts index 264ccbbdce..36e2321743 100644 --- a/web_src/js/modules/toast.ts +++ b/web_src/js/modules/toast.ts @@ -5,6 +5,9 @@ import Toastify from 'toastify-js'; // don't use "async import", because when ne import type {Intent} from '../types.ts'; import type {SvgName} from '../svg.ts'; import type {Options} from 'toastify-js'; +import type StartToastifyInstance from 'toastify-js'; + +export type Toast = ReturnType<typeof StartToastifyInstance>; type ToastLevels = { [intent in Intent]: { @@ -38,7 +41,7 @@ type ToastOpts = { } & Options; // See https://github.com/apvarun/toastify-js#api for options -function showToast(message: string, level: Intent, {gravity, position, duration, useHtmlBody, preventDuplicates = true, ...other}: ToastOpts = {}) { +function showToast(message: string, level: Intent, {gravity, position, duration, useHtmlBody, preventDuplicates = true, ...other}: ToastOpts = {}): Toast { const body = useHtmlBody ? String(message) : htmlEscape(message); const key = `${level}-${body}`; @@ -75,14 +78,14 @@ function showToast(message: string, level: Intent, {gravity, position, duration, return toast; } -export function showInfoToast(message: string, opts?: ToastOpts) { +export function showInfoToast(message: string, opts?: ToastOpts): Toast { return showToast(message, 'info', opts); } -export function showWarningToast(message: string, opts?: ToastOpts) { +export function showWarningToast(message: string, opts?: ToastOpts): Toast { return showToast(message, 'warning', opts); } -export function showErrorToast(message: string, opts?: ToastOpts) { +export function showErrorToast(message: string, opts?: ToastOpts): Toast { return showToast(message, 'error', opts); } |