diff --git a/components/notification/index.tsx b/components/notification/index.tsx index 21b5730522..c6a8b712c2 100644 --- a/components/notification/index.tsx +++ b/components/notification/index.tsx @@ -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) => void>; +const api = apiBase as any as NotificationApi; +const iconTypes: IconType[] = ['success', 'info', 'warning', 'error']; +iconTypes.forEach(type => { api[type] = args => api.open({ ...args,