Type Alias AllDisjoint<First, Rest>Protected

AllDisjoint<First, Rest>: Rest extends [infer Head, ...(infer Tail)]
    ? Head extends string
        ? [First & Head] extends [never]
            ? AllDisjoint<First, Tail extends string[]
                ? Tail
                : []>
            : {
                __error__: `overlaps on ${First}`;
            }
        : true
    : true

Returns true if there is no intersection between First the elements of Rest.

Type Parameters

  • First extends string

    A string type

  • Rest extends string[]

    A tuple of string types

true if there is no intersection between First the elements of Rest, otherwise a custom error type.

type ReturnsTrue = AllDisjoint<'a', ['b' | 'c', 'd']>;
// true

type ReturnsError = AllDisjoint<'c', ['b' | 'c', 'c']>;
// { __error__: 'overlaps on c' }