From e75dbe1fee378d1aab81091c30da7b29be9e9a5f Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 20 Jun 2024 17:06:09 +0200 Subject: [PATCH] `IntRange`: Document lack of support for negative numbers Fixes #895 --- source/int-range.d.ts | 2 +- test-d/int-range.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/source/int-range.d.ts b/source/int-range.d.ts index 01f6dee00..77ded8f99 100644 --- a/source/int-range.d.ts +++ b/source/int-range.d.ts @@ -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: diff --git a/test-d/int-range.ts b/test-d/int-range.ts index 52c4f996c..2564809cc 100644 --- a/test-d/int-range.ts +++ b/test-d/int-range.ts @@ -16,3 +16,10 @@ expectType<10>(stepTest2); declare const maxNumberTest: IntRange<0, 999>; expectAssignable(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);