mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
Merge pull request #7373 from Microsoft/limitInferenceDepth
set the maximum depth to explore during type inference
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user