aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/modules/toast.ts
diff options
context:
space:
mode:
Diffstat (limited to 'web_src/js/modules/toast.ts')
-rw-r--r--web_src/js/modules/toast.ts11
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);
}