Skip to content

Commit 8ce46ab

Browse files
authored
fix(notification): 完善notification类型 (#4346)
1 parent c20c1f2 commit 8ce46ab

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

components/notification/index.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ function notice(args: NotificationArgsProps) {
212212
);
213213
}
214214

215-
const api: any = {
215+
const apiBase = {
216216
open: notice,
217217
close(key: string) {
218218
Object.keys(notificationInstance).forEach(cacheKey =>
@@ -228,7 +228,11 @@ const api: any = {
228228
},
229229
};
230230

231-
['success', 'info', 'warning', 'error'].forEach(type => {
231+
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 => {
232236
api[type] = args =>
233237
api.open({
234238
...args,

0 commit comments

Comments
 (0)