PokéRogue
    Preparing search index...

    Type Alias Sum<A, B>

    Sum: number extends A
    | B
        ? number
        : A extends B & (PositiveInfinity | NegativeInfinity)
            ? A
            : (A | B) extends PositiveInfinity | NegativeInfinity
                ? number
                : A extends PositiveInfinity
                | NegativeInfinity
                    ? A
                    : B extends PositiveInfinity
                    | NegativeInfinity
                        ? B
                        : A extends 0
                            ? B
                            : B extends 0 ? A : A extends ReverseSign<B> ? 0 : SumPostChecks<A, B>

    Returns the sum of two numbers.

    Note:

    • A or B can only support -999 ~ 999.

    Type Parameters

    • A extends number
    • B extends number
    import type {Sum, PositiveInfinity, NegativeInfinity} from 'type-fest';

    type A = Sum<111, 222>;
    //=> 333

    type B = Sum<-111, 222>;
    //=> 111

    type C = Sum<111, -222>;
    //=> -111

    type D = Sum<PositiveInfinity, -9999>;
    //=> Infinity

    type E = Sum<PositiveInfinity, NegativeInfinity>;
    //=> number