From 52e10d3a980f2ebb390f589dc8cc5c62613e73ca Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 30 Oct 2021 08:24:28 -0700 Subject: [PATCH] Always set last type id --- src/compiler/checker.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dc40f7b15a0..daade99214e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -20366,12 +20366,14 @@ namespace ts { let lastTypeId = 0; for (let i = 0; i < depth; i++) { const t = stack[i]; - // We only count occurrences with higher type ids than the previous occurrences, since higher - // type ids are an indicator of newer instantiations caused by recursion. - if (getRecursionIdentity(t) === identity && t.id >= lastTypeId) { - count++; - if (count >= maxDepth) { - return true; + if (getRecursionIdentity(t) === identity) { + // We only count occurrences with a higher type id than the previous occurrence, since higher + // type ids are an indicator of newer instantiations caused by recursion. + if (t.id >= lastTypeId) { + count++; + if (count >= maxDepth) { + return true; + } } lastTypeId = t.id; }