type-challenges/questions/5-extreme-readonly-keys
2020-07-31 17:50:09 +08:00
..
2020-07-31 17:50:09 +08:00
2020-07-28 11:59:39 +08:00
2020-07-31 17:50:09 +08:00
2020-07-28 11:59:39 +08:00
2020-07-28 11:59:39 +08:00

Get Readonly Keys extreme #utils #object-keys

by Anthony Fu @antfu

Take the Challenge

Implement a generic GetReadonlyKeys<T> that returns a union of the readonly keys of an Object.

For example

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

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

Back Share your Solutions Check out Solutions