TypeScript tutorialLesson 33Free preview
TS Index Signatures
This lesson is part of TypeScript · All levels
Summary
Index signature declares a type of value for all keys of a particular type, such that each string becomes a number. This pattern is useful for dictionaries, configurations, or labelled scores. The entire concrete property on the interface must be compatible with the index type.
Key points
- Index signature uses [key: type]: typeValue
- Can use a string or a number key
- All properties must be compatible with the index
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.