34 lessons
The Certificate
Indexed Acess types help look up a defined property on a different type.
A standard example of the syntax and behavior of indexed access types in code is given below:
type FBoy= { age: number; name: string; hot: boolean }; type Age = FBoy["age"];
Now we can unions (keyof) as the indexed type is a type.
type I1 = FBoy["age" | "name"]; type I2 = FBoy[keyof FBoy]; type HotOrName = "hot" | "name"; type I3 = Person[HotOrName];