Extracts from union type T those types that are assignable to U. This is a stricter version of the built-in Extract that requires U to extend T.
T
U
Extract
The union type to extract from.
The type to extract, must extend T.
The intersection of T and U.
type Union = 'a' | 'b' | 'c';type Extracted = StrictExtract<Union, 'a' | 'b'>; // 'a' | 'b'// type Invalid = StrictExtract<Union, 'a' | 'd'>; // Error: 'd' is not assignable to Union Copy
type Union = 'a' | 'b' | 'c';type Extracted = StrictExtract<Union, 'a' | 'b'>; // 'a' | 'b'// type Invalid = StrictExtract<Union, 'a' | 'd'>; // Error: 'd' is not assignable to Union
Extracts from union type
Tthose types that are assignable toU. This is a stricter version of the built-inExtractthat requiresUto extendT.