ts - 常用技巧

ru shui 2021-06-28 Typescript
  • Typescript
  • Tips
Less than 1 minute

# 提取接口中的 keys 作为 options

interface Person {
  name: string
  age: number
}

type OptionsOfPerson = {
  [prop in keyof Person]: boolean
}
1
2
3
4
5
6
7
8

Last update: August 27, 2021 23:37
Contributors: Laishuxin