Answers for "typescript enum to string"

14

typescript enum to string

enum AnEnum {
    One = 1,
    Two = 2
}
let stringOne = AnEnum[1]; // "One"
let stringTwo = AnEnum[AnEnum.Two]; // "Two"
Posted by: Guest on March-30-2020
5

enum in ts

enum Direction {
    Up,
    Down,
    Left,
    Right,
}
Posted by: Guest on May-28-2020
3

ts enum

enum Response {
    No = 0,
    Yes = 1,
}

function respond(recipient: string, message: Response): void {
    // ...
}

respond("Princess Caroline", Response.Yes)
Posted by: Guest on May-05-2020
-1

typescript enum value to enum

enum Number {
  One,
  Two
}  

const numberOne: Number = "One" as Number;
const otherNumberOne: Number = Number.One;

const stringOne = Number[Number.One];
Posted by: Guest on August-31-2020

Code answers related to "TypeScript"

Browse Popular Code Answers by Language