A generic type variable constrained by the number, by default of the value captured from the supplied indicates the minimum range type of a new Range instance.
range.class.ts
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
) { }
}
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.
) { }
}
A generic type variable constrained by the number, by default of the value captured from the supplied indicates the maximum range type of a new Range instance.
A generic type variable constrained by the number, by default of the value equal to 1, optionally captured from the supplied indicates the range step type of a new Range instance.