Skip to content

Commit

Permalink
Fix type of mw.notify & mw.notification (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnYiEE authored Jun 10, 2023
1 parent f088429 commit 97e4586
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions mw/notification.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
interface Notification {
start: () => void;
pause: () => void;
resume: () => void;
close: () => void;
$notification: JQuery;
autoHideSeconds: number;
isOpen: boolean;
isPaused: boolean;
options: Partial<typeof mw.notification.defaults>;
timeout: {
set: typeof setTimeout;
clear: typeof clearTimeout;
};
}

declare global {
namespace mw {
/**
Expand All @@ -22,11 +38,7 @@ declare global {
function notify(
message: string | JQuery | HTMLElement | HTMLElement[],
options?: Partial<typeof notification.defaults>
): {
pause: () => void;
resume: () => void;
close: () => void;
};
): JQuery.Promise<Notification>;

namespace notification {
function pause(): void;
Expand All @@ -36,12 +48,15 @@ declare global {
function notify(
message: string | JQuery | HTMLElement | HTMLElement[],
options?: Partial<typeof notification.defaults>
): {
pause: () => void;
resume: () => void;
close: () => void;
): Notification;

const autoHideSeconds: {
short: number;
long: number;
};

const autoHideLimit: number;

/**
* The defaults for notify options parameter.
* @param autoHide A boolean indicating whether the notification should automatically
Expand All @@ -61,16 +76,16 @@ declare global {
* @param id HTML ID to set on the notification element.
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.notification-property-defaults
*/
let defaults: {
const defaults: {
autoHide: boolean;
autoHideSeconds: "short" | "long";
tag: string | null;
title: string | null;
type: "info" | "warn" | "error" | "success";
visibleTimeout: boolean;
id: string;
classes: string | string[];
};
let autoHideLimit: number;
}
}
}
Expand Down

0 comments on commit 97e4586

Please sign in to comment.