Skip to content

Commit abc61a0

Browse files
committedAug 16, 2019
Add InferencePriority.Circularity per CR feedback
1 parent 86d9153 commit abc61a0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed
 

‎src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15696,7 +15696,7 @@ namespace ts {
1569615696
inferencePriority = Math.min(inferencePriority, status);
1569715697
return;
1569815698
}
15699-
(visited || (visited = createMap<number>())).set(key, -1);
15699+
(visited || (visited = createMap<number>())).set(key, InferencePriority.Circularity);
1570015700
const saveInferencePriority = inferencePriority;
1570115701
inferencePriority = InferencePriority.MaxValue;
1570215702
action(source, target);
@@ -15789,7 +15789,7 @@ namespace ts {
1578915789
inferencePriority = InferencePriority.MaxValue;
1579015790
inferFromTypes(sources[i], t);
1579115791
if (inferencePriority === priority) matched[i] = true;
15792-
inferenceCircularity = inferenceCircularity || inferencePriority < 0;
15792+
inferenceCircularity = inferenceCircularity || inferencePriority === InferencePriority.Circularity;
1579315793
inferencePriority = Math.min(inferencePriority, saveInferencePriority);
1579415794
}
1579515795
}
@@ -15901,7 +15901,7 @@ namespace ts {
1590115901
const symbol = isNonConstructorObject ? target.symbol : undefined;
1590215902
if (symbol) {
1590315903
if (contains(symbolStack, symbol)) {
15904-
inferencePriority = -1;
15904+
inferencePriority = InferencePriority.Circularity;
1590515905
return;
1590615906
}
1590715907
(symbolStack || (symbolStack = [])).push(symbol);

‎src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4474,6 +4474,7 @@ namespace ts {
44744474
MaxValue = 1 << 8, // Seed for inference priority tracking
44754475

44764476
PriorityImpliesCombination = ReturnType | MappedTypeConstraint | LiteralKeyof, // These priorities imply that the resulting type should be a combination of all candidates
4477+
Circularity = -1, // Inference circularity (value less than all other priorities)
44774478
}
44784479

44794480
/* @internal */

0 commit comments

Comments
 (0)
Please sign in to comment.