PokéRogue
    Preparing search index...

    Type Alias IntRange<Start, End, Step>

    Generate a union of numbers between a specified start (inclusive) and end (exclusive), with an optional step.

    You skip over numbers using the Step parameter (defaults to 1). For example, IntRange<0, 10, 2> will create a union of 0 | 2 | 4 | 6 | 8.

    Note: Start or End must be non-negative and smaller than 1000.

    Use-cases:

    1. This can be used to define a set of valid input/output values. for example:

    Type Parameters

    • Start extends number
    • End extends number
    • Step extends number = 1
    import type {IntRange} from 'type-fest';

    type Age = IntRange<0, 20>;
    //=> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19

    type FontSize = IntRange<10, 20>;
    //=> 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19

    type EvenNumber = IntRange<0, 11, 2>;
    //=> 0 | 2 | 4 | 6 | 8 | 10
    1. This can be used to define random numbers in a range. For example, type RandomNumber = IntRange<0, 100>;
    import type {IntRange} from 'type-fest';

    type ZeroToNine = IntRange<0, 10>;
    //=> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

    type Hundreds = IntRange<100, 901, 100>;
    //=> 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900