TypeScript tutorialLesson 18Free preview
TS Keyof
This lesson is part of TypeScript · All levels
Summary
The keyof operator takes the list of keys from a type and produces a literal union. The result can be used to write a secure util against a wrongly typed property name.
Key points
- Keyof produces a literal union string
- Safe against typing property names
- Can be combined with T[K]
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.