Skip to content

Commit 4e3397e

Browse files
committed
Mark ranges as subtypes of containing ranges
For example, (>= 1) is a subtype of (> 0). This doesn't really matter in most cases though, because unions don't often reduce subtypes, and that is the only time where the subtype relation is actually used.
1 parent e9913e9 commit 4e3397e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11531,7 +11531,7 @@ namespace ts {
1153111531

1153211532
function isRangeTypeRelatedTo(source: Type, target: RangeType, relation: Map<RelationComparisonResult>) {
1153311533
if (relation === comparableRelation) return true;
11534-
if (relation === assignableRelation || relation === definitelyAssignableRelation) {
11534+
if (relation === assignableRelation || relation === definitelyAssignableRelation || relation === subtypeRelation) {
1153511535
if (source.flags & TypeFlags.Range) {
1153611536
return isRangeContainedBy(<RangeType>source, target);
1153711537
}
@@ -11542,7 +11542,6 @@ namespace ts {
1154211542
return false;
1154311543
}
1154411544

11545-
// A range "contained" by another is essentially a subtype of it
1154611545
function isRangeContainedBy(source: RangeType, target: RangeType) {
1154711546
if (!source.min && target.min) return false;
1154811547
if (!source.max && target.max) return false;

0 commit comments

Comments
 (0)