Created
December 14, 2018 19:22
-
-
Save kofno/ab952a3576b8ac4269b565738615490f to your computer and use it in GitHub Desktop.
Alert types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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