Last active
December 16, 2022 05:42
-
-
Save MauricioRobayo/434bcc71f19a8737e134fb1a88f707d3 to your computer and use it in GitHub Desktop.
Objects vs Enums https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums #gogofast
This file contains 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 Direction = { | |
Up: 0, | |
Down: 1, | |
Left: 2, | |
Right: 3, | |
} as const; | |
type Direction = typeof Direction[keyof typeof Direction]; | |
function run(dir: Direction) {} | |
run(Direction.Right); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment