We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c20c1f2 commit 8ce46abCopy full SHA for 8ce46ab
components/notification/index.tsx
@@ -212,7 +212,7 @@ function notice(args: NotificationArgsProps) {
212
);
213
}
214
215
-const api: any = {
+const apiBase = {
216
open: notice,
217
close(key: string) {
218
Object.keys(notificationInstance).forEach(cacheKey =>
@@ -228,7 +228,11 @@ const api: any = {
228
},
229
};
230
231
-['success', 'info', 'warning', 'error'].forEach(type => {
+type NotificationApi = typeof apiBase &
232
+ Record<IconType | 'warn', (args: Omit<NotificationArgsProps, 'type'>) => void>;
233
+const api = apiBase as any as NotificationApi;
234
+const iconTypes: IconType[] = ['success', 'info', 'warning', 'error'];
235
+iconTypes.forEach(type => {
236
api[type] = args =>
237
api.open({
238
...args,
0 commit comments