Generic type variables
The `Range` object generic type variables
Range<Min,Max,Step>
Range<Min,Max,Step>A generic type variable constrained by the number, by default of the value captured from the supplied min indicates the minimum range type of a new Range instance.
class Range<
Min extends number, // <--- Declare generic type variable Min.
Max extends number,
Step extends number = 1
> {
constructor(
min: Min, // <--- Capture generic type variable Min.
max: Max,
value?: number,
step: Step = 1 as Step
) { }
}Range<Min,Max,Step>
Range<Min,Max,Step>A generic type variable constrained by the number, by default of the value captured from the supplied max indicates the maximum range type of a new Range instance.
class Range<
Min extends number,
Max extends number, // <--- Declare generic type variable Max.
Step extends number = 1
> {
constructor(
min: Min,
max: Max, // <--- Capture generic type variable Max.
value?: number,
step: Step = 1 as Step
) {}
}Range<Min,Max,Step>
Range<Min,Max,Step>A generic type variable constrained by the number, by default of the value equal to 1, optionally captured from the supplied step indicates the range step type of a new Range instance.
class Range<
Min extends number,
Max extends number,
Step extends number = 1 // <--- Declare generic type variable Step.
> {
constructor(
min: Min,
max: Max,
value?: number,
step: Step = 1 as Step // <--- Capture generic type variable Step.
) { }
}Last updated