Package: effect
Module: Types
Checks whether a type T is a union type.
When to use
Use to branch type-level logic depending on whether a type is a union.
Details
[T] against [UnionToIntersection<T>]. If they differ, T
must be a union.true if T is a union of two or more members.false for single types, never, or any.Example (Detecting union types)
import type { Types } from "effect"
type Yes = Types.IsUnion<"a" | "b"> // true
type No = Types.IsUnion<string> // false
See
UnionToIntersectionSignature
type IsUnion<T> = [T] extends [UnionToIntersection<T>] ? false : true
Since v4.0.0