type-fest icon indicating copy to clipboard operation
type-fest copied to clipboard

IntRange Inclusive

Open BrendanC23 opened this issue 1 year ago • 3 comments

The IntRange type was added in this PR. As mentioned in the documentation The numbers are created from the given Start(inclusive) parameter to the givenEnd (exclusive) parameter..

Could an option be added to this type that would allow the end parameter to be inclusive? For example,

IntRangeInclusive<0, 3> = 0 | 1 | 2 | 3

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • The funding will be given to active contributors.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

BrendanC23 avatar Jan 23 '24 16:01 BrendanC23

Yeah, we should add a inclusive range method too.

Alternative name: IntClosedRange

sindresorhus avatar Jan 23 '24 18:01 sindresorhus

Yes please, would be easy to define it

type IntClosedRange<Start extends number, End extends number> = IntRange<Start, End> | End

lucasteles avatar Jan 26 '24 20:01 lucasteles

Yes please, would be easy to define it

type IntClosedRange<Start extends number, End extends number> = IntRange<Start, End> | End

I think it should be

type IntClosedRange<Start extends number, End extends number, Skip extends number> = IntRange<Start, Add<End, 1>, Skip>

Emiyaaaaa avatar Jan 29 '24 06:01 Emiyaaaaa