halo - v1.0.0
    Preparing search index...

    Type Alias OnlyOne<T>

    OnlyOne: {
        [K in keyof T]: { [P in K]: T[P] } & Partial<
            Record<Exclude<keyof T, K>, never>,
        >
    }[keyof T]

    OnlyOne is a utility type that ensures only one of the specified keys in T can be present at a time. It allows for defining types where only one property can be set, while the others must be never.

    Type Parameters

    • T

      The type to apply the OnlyOne constraint to.

    The keys of T that are mutually exclusive.

    type Example = OnlyOne<{ a: string; b: number; c: boolean }>
    // This will create a type where only one of 'a', 'b', or 'c' can be present at a time.