NaturalNumbersLessThanOrEqualTo (Type)
Type Aliases
NaturalNumbersLessThanOrEqualTo<N, T>
type NaturalNumbersLessThanOrEqualTo<N, T>: T extends [unknown, ...(infer Tail)] ? Tail["length"] extends N ? T[number] : NaturalNumbersLessThanOrEqualTo<N, [...T, T["length"]]> : NaturalNumbersLessThanOrEqualTo<N, [...T, T["length"]]>;
Helper type to get a range of integers between 0 and N.
From: https://stackoverflow.com/questions/39494689/is-it-possible-to-restrict-number-to-a-certain-range
Type Parameters
Type Parameter | Default type |
---|---|
N extends number | - |
T extends number [] | [] |