Check if a union type includes a specific type.
A union type
The type to check for membership in the union
Evaluates to true if the type T is assignable to the union U, otherwise evaluates to false.
true
T
U
false
type U = string | number | boolean;type HasString = UnionHas< U, string >; // truetype HasDate = UnionHas< U, Date >; // false Copy
type U = string | number | boolean;type HasString = UnionHas< U, string >; // truetype HasDate = UnionHas< U, Date >; // false
Check if a union type includes a specific type.