(type, stack, depth, maxDepth)
| 67179 | // has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]`. In such cases we need |
| 67180 | // to terminate the expansion, and we do so here. |
| 67181 | function isDeeplyNestedType(type, stack, depth, maxDepth) { |
| 67182 | if (maxDepth === void 0) { maxDepth = 3; } |
| 67183 | if (depth >= maxDepth) { |
| 67184 | var identity_2 = getRecursionIdentity(type); |
| 67185 | var count = 0; |
| 67186 | var lastTypeId = 0; |
| 67187 | for (var i = 0; i < depth; i++) { |
| 67188 | var t = stack[i]; |
| 67189 | if (getRecursionIdentity(t) === identity_2) { |
| 67190 | // We only count occurrences with a higher type id than the previous occurrence, since higher |
| 67191 | // type ids are an indicator of newer instantiations caused by recursion. |
| 67192 | if (t.id >= lastTypeId) { |
| 67193 | count++; |
| 67194 | if (count >= maxDepth) { |
| 67195 | return true; |
| 67196 | } |
| 67197 | } |
| 67198 | lastTypeId = t.id; |
| 67199 | } |
| 67200 | } |
| 67201 | } |
| 67202 | return false; |
| 67203 | } |
| 67204 | // The recursion identity of a type is an object identity that is shared among multiple instantiations of the type. |
| 67205 | // We track recursion identities in order to identify deeply nested and possibly infinite type instantiations with |
| 67206 | // the same origin. For example, when type parameters are in scope in an object type such as { x: T }, all |
no test coverage detected
searching dependent graphs…