by Anthony Fu @antfu
实现泛型GetReadonlyKeys<T>
,GetReadonlyKeys<T>
返回由对象 T 所有只读属性的键组成的联合类型。
例如
interface Todo {
readonly title: string
readonly description: string
completed: boolean
}
type Keys = GetReadonlyKeys<Todo> // expected to be "title" | "description"