ContainsUnion<T, U>
ts
type ContainsUnion<T, U> = [U] extends [T] ? true : false;Defined in: types.ts:71
Checks whether type U is fully contained within type T (i.e., whether U is a subtype of T).
Type Parameters
| Type Parameter | Description |
|---|---|
T | The broader type |
U extends T | The type to check, constrained to extend T |
Example
ts
type A = ContainsUnion<string | number, string>; // true
type B = ContainsUnion<string, string | number>; // false