TypeScript 学习笔记(一)

· 272 words · 2 min

enum Color {
  Red,
  Green,
  Blue,
}

console.log(Color.Red, Color.Green, Color.Blue) // 0, 1, 2
console.log(Color[0], Color[1], Color[2]) // Red, Green, Blue
let someValue: any = 'this is a string'
let strLength: number = (someValue as string).length
TypeScript