Type Alias Merge<A, B, Options>

Merge: Or<
    IsAny<A>,
    IsAny<B>,
    any,
    Or<
        IsNever<A>,
        IsNever<B>,
        never,
        IsDisjoint<A, B> extends true
            ? A & B
            : [keyof A, keyof B] extends [
                infer KA extends KeyTypes,
                infer KB extends KeyTypes,
            ]
                ? IsLiteral<KA> extends true
                    ? IsLiteral<KB> extends true
                        ? [OptionalKeys<A>, OptionalKeys<B>] extends [
                            infer PKA extends KeyTypes,
                            infer PKB extends KeyTypes,
                        ]
                            ? (
                                IsNotNever<(...), (...)> extends infer R extends (...)
                                    ? { [k in (...)]?: (...) }
                                    : unknown
                            ) & (
                                IsNotNever<(...), (...)> extends infer R extends (...)
                                    ? { [k in (...)]: (...) }
                                    : unknown
                            ) & (
                                IsNotNever<(...), (...)> extends infer R extends (...)
                                    ? { [k in (...)]: (...) }
                                    : unknown
                            ) & (
                                IsNotNever<(...), (...)> extends infer R extends (...)
                                    ? { [k in (...)]: (...) }
                                    : unknown
                            )
                            : never
                        : (
                            IsNotNever<Exclude<(...), (...)>, { selection: ... }> extends infer R extends
                                KeyTypes
                                ? { [k in R]: (...)[(...)] }
                                : unknown
                        ) & (
                            IsNotNever<Exclude<(...), (...)>, { selection: ... }> extends infer R extends
                                KeyTypes
                                ? { [k in R]: (...)[(...)] }
                                : unknown
                        ) & (
                            IsNotNever<(...) & (...), { selection: ... }> extends infer R extends
                                KeyTypes
                                ? { [k in R]: (...)
                                | (...) }
                                : unknown
                        )
                    : IsLiteral<KB> extends true
                        ? { [k in Exclude<KA, KB>]: A[k] } & { [k in keyof B]: B[k] }
                        : (
                            IsNotNever<Exclude<(...), (...)>, { selection: ... }> extends infer R extends
                                KeyTypes
                                ? { [k in R]: (...)[(...)] }
                                : unknown
                        ) & (
                            IsNotNever<Exclude<(...), (...)>, { selection: ... }> extends infer R extends
                                KeyTypes
                                ? { [k in R]: (...)[(...)] }
                                : unknown
                        ) & (
                            IsNotNever<(...) & (...), { selection: ... }> extends infer R extends
                                KeyTypes
                                ? { [k in R]: (...)
                                | (...) }
                                : unknown
                        )
                : never,
    >,
>

⚗️ transform 🔢 customizable

Merges type A and type B.

This type performs the same operations as { ...a, ...b } but at the type level.

It handles cases like A or B are Record, joining between required and optional props, etc.

Type Parameters