Jenis TypeScript dari nilai enum
enum Weekday {
MONDAY = 'mon',
TUESDAY = 'tue',
WEDNESDAY = 'wed'
}
type WeekdayType = `${Weekday}`;
Lively Lark
enum Weekday {
MONDAY = 'mon',
TUESDAY = 'tue',
WEDNESDAY = 'wed'
}
type WeekdayType = `${Weekday}`;
enum AnEnum {
One = 1,
Two = 2
}
let stringOne = AnEnum[1]; // "One"
let stringTwo = AnEnum[AnEnum.Two]; // "Two"
enum EMoney {
gopay = 'gopay',
dana = 'dana',
ovo = 'ovo'
}
enum Bank {
bca = 'bca',
mandiri = 'mandiri',
bri = 'bri'
}
interface OnlineShop<T> {
payment: T
}
const payment: OnlineShop<Bank> = {
payment: Bank.bca
}
enum Number {
One,
Two
}
const numberOne: Number = "One" as Number;
const otherNumberOne: Number = Number.One;
const stringOne = Number[Number.One];