1enum AnEnum {
2 One = 1,
3 Two = 2
4}
5let stringOne = AnEnum[1]; // "One"
6let stringTwo = AnEnum[AnEnum.Two]; // "Two"
1enum Response {
2 No = 0,
3 Yes = 1,
4}
5
6function respond(recipient: string, message: Response): void {
7 // ...
8}
9
10respond("Princess Caroline", Response.Yes)
11
1enum Number {
2 One,
3 Two
4}
5
6const numberOne: Number = "One" as Number;
7const otherNumberOne: Number = Number.One;
8
9const stringOne = Number[Number.One];