Horje
typescript enum Code Example
typescript type from enum values
enum Weekday {
  MONDAY = 'mon',
  TUESDAY = 'tue',
  WEDNESDAY = 'wed'
}

type WeekdayType = `${Weekday}`;
typescript enum to string
enum AnEnum {
    One = 1,
    Two = 2
}
let stringOne = AnEnum[1]; // "One"
let stringTwo = AnEnum[AnEnum.Two]; // "Two"
enum usage typescript
enum UserResponse {
  No = 0,
  Yes = 1,
}

function respond(recipient: string, message: UserResponse): void {
  console.log(recipient, message); // "Princess Caroline",  1
}

respond("Princess Caroline", UserResponse.Yes);
ts enum
enum vscode {
    good,bad,medium
}

console.log(vscode.bad)
typescript enum
enum Sides {LEFT, RIGHT};
Sides.LEFT;  // 0
Sides.RIGHT; // 1

const typeFromEnum: Sides.LEFT = Sides.LEFT; // Enums become types!

console.log(Sides);   // { '0': 'LEFT', '1': 'RIGHT', LEFT: 0, RIGHT: 1 } 

type leftOrRight = keyof typeof Sides; // 'LEFT' | 'RIGHT'

let sideName: string = Sides[0];  // 'LEFT'  reverse mapping


enum EnumWithString {
  X = "XX",
  Y = "YY",
};
console.log(EnumWithString); // { X: 'XX', Y: 'YY' }  no reverse mapping
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];




Typescript

Related
graphql mutation is not displaying array of objects in express-graphql Code Example graphql mutation is not displaying array of objects in express-graphql Code Example
sarasota bowling alley bomb threats incident Code Example sarasota bowling alley bomb threats incident Code Example
Job for pm2-rfb.service failed because the service did not take the steps required by its unit configuration. Code Example Job for pm2-rfb.service failed because the service did not take the steps required by its unit configuration. Code Example
how can i get 2 inputs in singal line seprated by space Code Example how can i get 2 inputs in singal line seprated by space Code Example
typescript key as string Code Example typescript key as string Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7