From the course: TypeScript Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Indexed access types

Indexed access types

- [Instructor] In this video, I'm going to show you how to determine the type of a certain property or multiple properties of a target object using something called an indexed access type. As its name implies, the syntax for an indexed access type is the same as the JavaScript syntax for accessing a property of an object using the index syntax like this. If I hover over the type, I can see that the type of Awesome matches the type of the id property on the Contact type, number. How is this useful? Well, take a look at line 19 where I have a property named contactId, which references the ID property of the contact type. Well, at least its name references the ID property but its type just happens to be the same. There's no direct connection between the two. So let's make one. While I haven't really changed the type of the contactId property here, I have done a much better job of showing my intention that…

Contents