Skip to content

Latest commit

 

History

History
17 lines (12 loc) · 2.04 KB

File metadata and controls

17 lines (12 loc) · 2.04 KB

获取只读属性 地狱 #utils #object-keys

by Anthony Fu @antfu

接受挑战    English 日本語 한국어 Português (BR)

实现泛型GetReadonlyKeys<T>GetReadonlyKeys<T>返回由对象 T 所有只读属性的键组成的联合类型。

例如

interface Todo {
  readonly title: string
  readonly description: string
  completed: boolean
}

type Keys = GetReadonlyKeys<Todo> // expected to be "title" | "description"

返回首页 分享你的解答 查看解答