Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 529 Bytes

File metadata and controls

43 lines (31 loc) · 529 Bytes

typelab / assertions / IsUnion

type IsUnion<T> = IfUnion<T, true, false>;

Checks if a given type T is union type.

Type Parameters

Type Parameter Description

T

The type to be checked.

Returns

true if T is union type, false otherwise.

Example

type Valid = IsUnion<string | number>; // true
type Invalid = IsUnion<string>; // false