Skip to content

Commit 8eb1ecb

Browse files
committed
Unravel some conditions
1 parent 9c4d309 commit 8eb1ecb

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/compiler/checker.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5195,23 +5195,27 @@ module ts {
51955195
else if (source.flags & TypeFlags.ObjectType && (target.flags & (TypeFlags.Reference | TypeFlags.Tuple) ||
51965196
(target.flags & TypeFlags.Anonymous) && target.symbol && target.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral))) {
51975197
// If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members
5198-
if (!isInProcess(source, target) && !(isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth))) {
5199-
if (depth === 0) {
5200-
sourceStack = [];
5201-
targetStack = [];
5202-
}
5203-
sourceStack[depth] = source;
5204-
targetStack[depth] = target;
5205-
depth++;
5206-
inferFromProperties(source, target);
5207-
inferFromSignatures(source, target, SignatureKind.Call);
5208-
inferFromSignatures(source, target, SignatureKind.Construct);
5209-
inferFromIndexTypes(source, target, IndexKind.String, IndexKind.String);
5210-
inferFromIndexTypes(source, target, IndexKind.Number, IndexKind.Number);
5211-
inferFromIndexTypes(source, target, IndexKind.String, IndexKind.Number);
5212-
depth--;
5198+
if (isInProcess(source, target)) {
5199+
return;
52135200
}
5214-
}
5201+
if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) {
5202+
return;
5203+
}
5204+
5205+
if (depth === 0) {
5206+
sourceStack = [];
5207+
targetStack = [];
5208+
}
5209+
sourceStack[depth] = source;
5210+
targetStack[depth] = target;
5211+
depth++;
5212+
inferFromProperties(source, target);
5213+
inferFromSignatures(source, target, SignatureKind.Call);
5214+
inferFromSignatures(source, target, SignatureKind.Construct);
5215+
inferFromIndexTypes(source, target, IndexKind.String, IndexKind.String);
5216+
inferFromIndexTypes(source, target, IndexKind.Number, IndexKind.Number);
5217+
inferFromIndexTypes(source, target, IndexKind.String, IndexKind.Number);
5218+
depth--; }
52155219
}
52165220

52175221
function inferFromProperties(source: Type, target: Type) {

0 commit comments

Comments
 (0)