set the maximum depth to explore during type inference
This commit is contained in:
parent
0f6dbd0250
commit
1589e4f57e
1 changed files with 6 additions and 0 deletions
|
@ -6585,6 +6585,7 @@ namespace ts {
|
|||
function inferTypes(context: InferenceContext, source: Type, target: Type) {
|
||||
let sourceStack: Type[];
|
||||
let targetStack: Type[];
|
||||
const maxDepth = 5;
|
||||
let depth = 0;
|
||||
let inferiority = 0;
|
||||
const visited: Map<boolean> = {};
|
||||
|
@ -6713,6 +6714,11 @@ namespace ts {
|
|||
if (isInProcess(source, target)) {
|
||||
return;
|
||||
}
|
||||
// we delibirately limit the depth we examine to infer types: this speeds up the overall inference process
|
||||
// and user rarely expects inferences to be made from the deeply nested constituents.
|
||||
if (depth > maxDepth) {
|
||||
return;
|
||||
}
|
||||
if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue