enum Sizes { Small = "small", Medium = "medium", Large = "large" } let selected: Sizes = Sizes.Samll; function updateSize(size: Sizes): void { selected = size; } updateSize(Sizes.large);
Interesting thing is that you can use enum as Type.
This is what compile to Javscript:
But if you add 'const' to enum:
const enum Sizes { Small = "small", Medium = "medium", Large = "large"
}
It compiles to such smaller amount code, with only necessary information