fix: Notice @ts-ignore (#2896)

thx
This commit is contained in:
TianHua Liu 2025-03-07 12:46:30 +08:00 committed by GitHub
parent a1944d1a90
commit 30ca547e50

View File

@ -103,7 +103,6 @@ interface NoticeInstance {
let parent: HTMLDivElement = null!;
// @ts-ignore
export const Notice: NoticeInstance = (props) => {
const { type, message, duration } = props;
@ -142,8 +141,8 @@ export const Notice: NoticeInstance = (props) => {
);
};
(["info", "error", "success"] as const).forEach((type) => {
Notice[type] = (message: ReactNode, duration?: number) => {
const createNoticeTypeFactory =
(type: keyof NoticeInstance) => (message: ReactNode, duration?: number) => {
// 确保消息不为空
if (!message) {
return;
@ -156,4 +155,7 @@ export const Notice: NoticeInstance = (props) => {
duration: type === "error" ? 8000 : duration || 1500,
});
};
});
Notice.info = createNoticeTypeFactory("info");
Notice.error = createNoticeTypeFactory("error");
Notice.success = createNoticeTypeFactory("success");