fix(notification): 完善notification类型 (#4346)

pull/4361/head
zanllp 2021-07-11 14:46:45 +08:00 committed by GitHub
parent c20c1f2a32
commit 8ce46ab1a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -212,7 +212,7 @@ function notice(args: NotificationArgsProps) {
);
}
const api: any = {
const apiBase = {
open: notice,
close(key: string) {
Object.keys(notificationInstance).forEach(cacheKey =>
@ -228,7 +228,11 @@ const api: any = {
},
};
['success', 'info', 'warning', 'error'].forEach(type => {
type NotificationApi = typeof apiBase &
Record<IconType | 'warn', (args: Omit<NotificationArgsProps, 'type'>) => void>;
const api = apiBase as any as NotificationApi;
const iconTypes: IconType[] = ['success', 'info', 'warning', 'error'];
iconTypes.forEach(type => {
api[type] = args =>
api.open({
...args,