Type Alias Equal<A, B, $O>

Equal: [A, B] extends [B, A]
    ? BothNever<
        A,
        B,
        $ResolveBranch<$O, [$Then]>,
        $ResolveBranch<$O, [$Else]>,
        BothAny<
            A,
            B,
            $ResolveBranch<$O, [$Then]>,
            $ResolveBranch<$O, [$Else]>,
            $Same<
                A,
                B,
                {
                    $else: [IsObject<A>, IsObject<B>] extends [true, true]
                        ? $Same<
                            Properties<A>,
                            Properties<B>,
                            {
                                $else: $ResolveBranch<$O, [$Else]>;
                                $then: [A, B] extends [(...args: ...) => ..., (...args: ...) => ...]
                                    ? IsEqual<
                                        P1,
                                        P2,
                                        $ResolveBranch<(...), (...)>,
                                        $ResolveBranch<(...), (...)>,
                                    >
                                    : $ResolveBranch<$O, [(...)]>;
                            },
                        >
                        : [A, B] extends [B, A]
                            ? $ResolveBranch<$O, [$Then]>
                            : $ResolveBranch<$O, [$Else]>;
                    $then: $ResolveBranch<$O, [$Then]>;
                },
            >,
        >,
    >
    : $ResolveBranch<$O, [$Else], A>

🎭 predicate

Validate A and B are "equal".

Note that intersection type checks only works at first level. It cannot be check recursively, or else will run into infinite recursion if the type includes recursive types.

Type Parameters

type R = Equal<undefined, undefined> // true

type R = Equal<never, undefined> // false
type R = Equal<unknown, undefined> // false
type R = Equal<string | boolean, undefined> // false

type R = Equal<string | undefined, undefined> // boolean

🔱 branching

Use unique branch identifiers to allow precise processing of the result.

type R = Equal<undefined, undefined, Equal.$Branch> // $Then
type R = Equal<string, undefined, Equal.$Branch> // $Else