Index Access Types
Index Access
π¨βπΌ Index access types let you extract property types from other types using
bracket notation.
type Recipe = {
title: string
author: { name: string; rating: 1 | 2 | 3 | 4 | 5 }
}
type TitleType = Recipe['title'] // string
type AuthorType = Recipe['author'] // { name: string; rating: 1 | 2 | 3 | 4 | 5 }
type RatingType = Recipe['author']['rating'] // 1 | 2 | 3 | 4 | 5
π¨ Open
and:
- Extract nested property types
- Use unions to get multiple property types at once
- Combine with
keyoffor flexible access


