Extract

This lesson explains the extract mapped type.

We'll cover the following

Description of Extract

The next mapped type is Extract. It allows us to extract from a set of types the one that is common in another type. The following code shows that the first generic argument has three variables (string, string[], and number) and the second generic type is unknown[], which means any kind of array. Extract returns string[] | number[]as a type because they are the only two that fulfill the conditions of an array.

Get hands-on with 1400+ tech skills courses.