Last active
October 3, 2022 11:57
-
-
Save GalindoSVQ/a0c8752733c649fa3d4ed99e13abe6ff to your computer and use it in GitHub Desktop.
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
| const bgColor: Record<string, string> = { | |
| Warning: 'orange', | |
| Error: 'red', | |
| Success: 'green', | |
| } | |
| type msgType = keyof typeof bgColor; | |
| function createPrintLog(type: msgType) { | |
| return function log(str: string) { | |
| return console.log(`%c ${type}: ${str} `, `background: ${bgColor[type]}; color: white`); | |
| } | |
| } | |
| const warning = createPrintLog("Warning") | |
| const error = createPrintLog("Error") | |
| const success = createPrintLog("Success") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment