TypeScript enums look like this:
enum Direction {
Up = "Up",
Down = "Down",
Left = "Left",
Right = "Right"
}
Enum declarations like these seem to me like unnecessary work. Especially with the DRY principle in mind. Isn't there a shorthand for declarations like this so that I don't need to repeat the values when they are equal to the keys? Sure, I could use numeric enums but they have that disadvantage that during debugging no meaningful values are present.
For example like the object literal shorthand from ES6:
firstname = 'firstname';
lastname = 'lastname';
fullname = {
firstname,
lastname
}
But even with this shorthand definition I still need to write for example firstname three times. Isn't there an easier way?
Would be nice if something like this would work:
// for enums:
string_enum Direction {
Up,
Down,
Left,
Right
}
// for object literals:
fullname: {
'firstname',
'lastname'
}