Extract<T, U>
The utility type that keeps only the members of union T that are assignable to U.
In more detail
Extract<HttpMethod, "GET"> leaves just "GET". It is the mirror image of Exclude.
Related terms
- Exclude<T, U> — The utility type that removes from union T every member assignable to U, such as Exclude<HttpMethod, "GET">.
- union type — A type that allows one of several listed types or values, written with a vertical bar, such as int | None in Python or "small" | "large" in TypeScript.
Taught in
- Union Utilities: Exclude, Extract, NonNullable And Awaited — Production TypeScript