Extract<Type, Members>

Only include members of Type which are assignable to Members.

Extract does the opposite of Exclude by only keeping the types that are assignable to another type. It is often useful for filtering in what you want from a union type.

You can also match object types based on structure, allowing you to filter a union of object types by key-value patterns.

Extract is implemented by returning never for types that do not extend the member type.

Was this page helpful?