keyof:类型 → key 联合

4 阅读1分钟

keyof:类型 → key 联合

type User = { id: number; name: string }

type UserKeys = keyof User
// UserKeys = 'id' | 'name'