IntRange: Document lack of support for negative numbers

Fixes #895
This commit is contained in:
Sindre Sorhus 2024-06-20 17:06:09 +02:00
parent 28efb2965c
commit e75dbe1fee
2 changed files with 8 additions and 1 deletions

View File

@ -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:

View File

@ -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);