ts-fortress
    Preparing search index...

    Type Alias IntRange<Start, End>

    IntRange: BoolAnd<
        TypeExtends<Start, PositiveRange>,
        TypeExtends<End, PositiveRange>,
    > extends true
        ? UintRange<Start & Uint11, End & Uint11>
        : BoolAnd<
            TypeExtends<Start, NegativeRange>,
            TypeExtends<End, PositiveRange>,
        > extends true
            ? NegativeIndex<Abs<Start>> | Index<End>
            : BoolAnd<
                TypeExtends<Start, PositiveRange>,
                TypeExtends<End, NegativeRange>,
            > extends true
                ? never
                : BoolAnd<
                    TypeExtends<Start, NegativeRange>,
                    TypeExtends<End, NegativeRange>,
                > extends true
                    ? RelaxedExclude<NegativeIndex<Abs<Start>>, NegativeIndex<Abs<End>>>
                    : never

    Creates a union of integer literals starting from Start (inclusive) up to End (exclusive). Unlike UintRange, the bounds may be negative.

    The bounds are limited to the signed 11-bit range: Start must be an Int11 (-1024 to 1023) and End must be an Int11 or 1024, so that a bound the union cannot represent fails with a readable constraint error instead of resolving to never. Ranges where Start >= End (including a positive Start with a negative End) resolve to never.

    Type Parameters

    • Start extends Int11

      The starting integer literal (inclusive).

    • End extends Int11 | 1024

      The ending integer literal (exclusive).

    A union type Start | Start + 1 | ... | End - 1.

    type R1 = IntRange<1, 5>; // 1 | 2 | 3 | 4
    type R2 = IntRange<-3, 3>; // -3 | -2 | -1 | 0 | 1 | 2
    type R3 = IntRange<-5, -1>; // -5 | -4 | -3 | -2
    type R4 = IntRange<3, -3>; // never
    type R5 = IntRange<5, 5>; // never