refine
refine copied to clipboard
[FEAT] Notification types
Is your feature request related to a problem? Please describe.
It's not possible to make a simple plain notification (in typescript) because useNotification requires type: "success" | "error" | "progress"
.
A plain notification would be needed when displaying a message or information.
It seems like the type restriction actually only is in the type definition.
Describe alternatives you've considered
Adding // @ts-expect-error type
before the property makes it possible to override the value with any string. Omitting the type
property or setting the type
property to an empty string ""
seems to make a simple plain notification. Setting the type
to "warning"
or "info"
seems to work fine as well.
const { open } = useNotification();
open?.({
message: "A plain notification",
// @ts-expect-error type
type: ""
})
Additional context
No response
Describe the thing to improve
Allow no or plain type as well as info and warning for notification options.
This can probably be done by extending the type of the type
property to accept additional types, including no type.
It would be preferable if the type
property also could be omitted to default to a plain notification.
interface OpenNotificationParams {
key?: string;
message: string;
+ type?: "" | "success" | "info" | "warning" | "error" | "progress";
- type: "success" | "error" | "progress";
description?: string;
cancelMutation?: () => void;
undoableTimeout?: number;
}