Skip to content

Commit 700427d

Browse files
committed
2 parents d46d79b + 0036db2 commit 700427d

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

types/message.d.ts

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,26 @@
22
// Definitions by: akki-jat <https://github.com/akki-jat>
33
// Definitions: https://github.com/vueComponent/ant-design-vue/types
44

5+
import { VNode, CreateElement } from 'vue'
6+
7+
export interface ThenableArgument {
8+
(val: any): void;
9+
}
10+
export interface MessageType {
11+
(): void;
12+
then: (fill: ThenableArgument, reject: ThenableArgument) => Promise<void>;
13+
promise: Promise<void>;
14+
}
15+
export type ConfigType = string | VNode | ((h: CreateElement) => VNode);
16+
export type ConfigDuration = number | (() => void);
17+
export type ConfigOnClose = () => void;
18+
519
export interface MessageOptions {
620
/**
721
* content of the message
822
* @type any (string | VNode | (h) => VNode)
923
*/
10-
content: any;
24+
content: ConfigType;
1125

1226
/**
1327
* time(seconds) before auto-dismiss, don't dismiss if set to 0
@@ -26,13 +40,13 @@ export interface MessageOptions {
2640
* Customized Icon
2741
* @type any (string | VNode | (h) => VNode)
2842
*/
29-
icon?: any;
43+
icon?: ConfigType;
3044

3145
/**
3246
* Specify a function that will be called when the message is closed
3347
* @type Function
3448
*/
35-
onClose?: () => void;
49+
onClose?: ConfigOnClose;
3650
key?: string | number;
3751
}
3852

@@ -65,14 +79,20 @@ export interface MessageConfigOptions {
6579
top?: string;
6680
}
6781

68-
export declare class Message {
69-
success(content: any, duration?: number, onClose?: () => void): Promise<any>;
70-
warning(content: any, duration?: number, onClose?: () => void): Promise<any>;
71-
warn(content: any, duration?: number, onClose?: () => void): Promise<any>;
72-
info(content: any, duration?: number, onClose?: () => void): Promise<any>;
73-
error(content: any, duration?: number, onClose?: () => void): Promise<any>;
74-
loading(content: any, duration?: number, onClose?: () => void): Promise<any>;
75-
open: (config: MessageOptions) => Promise<any>;
82+
export declare interface Message {
83+
success(content: MessageOptions): MessageType;
84+
success(content: ConfigType, duration?: ConfigDuration, onClose?: ConfigOnClose): MessageType;
85+
warning(content: MessageOptions): MessageType;
86+
warning(content: ConfigType, duration?: ConfigDuration, onClose?: ConfigOnClose): MessageType;
87+
warn(content: MessageOptions): MessageType;
88+
warn(content: ConfigType, duration?: ConfigDuration, onClose?: ConfigOnClose): MessageType;
89+
info(content: MessageOptions): MessageType;
90+
info(content: ConfigType, duration?: ConfigDuration, onClose?: ConfigOnClose): MessageType;
91+
error(content: MessageOptions): MessageType;
92+
error(content: ConfigType, duration?: ConfigDuration, onClose?: ConfigOnClose): MessageType;
93+
loading(content: MessageOptions): MessageType;
94+
loading(content: ConfigType, duration?: ConfigDuration, onClose?: ConfigOnClose): MessageType;
95+
open: (config: MessageOptions) => MessageType;
7696
config: (options: MessageConfigOptions) => void;
7797
destroy: () => void;
7898
}

0 commit comments

Comments
 (0)