Skip to content

Commit

Permalink
IntRange: Document lack of support for negative numbers
Browse files Browse the repository at this point in the history
Fixes #895
  • Loading branch information
sindresorhus committed Jun 20, 2024
1 parent 28efb29 commit e75dbe1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/int-range.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The numbers are created from the given `Start` (inclusive) parameter to the give
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 smaller than `1000`.
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:
Expand Down
7 changes: 7 additions & 0 deletions test-d/int-range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ expectType<10>(stepTest2);

declare const maxNumberTest: IntRange<0, 999>;
expectAssignable<number>(maxNumberTest);

// Not yet supported.
// declare const negative: IntRange<-1, 1>;
// expectType<-1 | 0 | 1>(negative);

// declare const negative2: IntRange<1, -1>;
// expectType<-1 | 0 | 1>(negative2);

0 comments on commit e75dbe1

Please sign in to comment.