Skip to content

Instantly share code, notes, and snippets.

@kofno
Created December 14, 2018 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kofno/ab952a3576b8ac4269b565738615490f to your computer and use it in GitHub Desktop.
Save kofno/ab952a3576b8ac4269b565738615490f to your computer and use it in GitHub Desktop.
Alert types
interface BaseAlert {
message: string;
display: boolean;
}
export interface Success extends BaseAlert {
kind: 'success';
}
export interface Info extends BaseAlert {
kind: 'info';
}
export interface Warn extends BaseAlert {
kind: 'warn';
}
export interface Error extends BaseAlert {
kind: 'error';
}
export type Alert = Success | Info | Warn | Error;
export const alert = (message: string, kind: Alert['kind']): Alert =>
({
message,
kind,
display: true,
} as Alert);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment