From the course: TypeScript Essential Training

Unlock the full course today

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

Keyof operator

Keyof operator

- [Instructor] The type script techniques that I've shown in the course up to this point have been pretty foundational, things that you'd use in just about any type script file you'll edit. From this video forward, however, I'm going to be getting into more advanced techniques, techniques that you may not use in your everyday type-script editing, but ones that will allow to be far more exact and expressive with your typings to increase the number of issues type script can detect and help you avoid. In this video, I'm going to be showing you how to reference the fields of a given type using the keyof operator. Using the keyof operator looks a lot like using the native instanceof operator. This line defines a type alias consisting of all of the properties on the contact type. In other words, a variable of this type may only contain values matching the names of the properties on the contact, ID, name, birth date and status.…

Contents