mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-13 06:20:23 -06:00
Merge pull request #7377 from Microsoft/port-7373-7163
Ports #7373 and #7163 in release-1.8
This commit is contained in:
commit
13e845a6b9
@ -6444,8 +6444,10 @@ 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> = {};
|
||||
inferFromTypes(source, target);
|
||||
|
||||
function isInProcess(source: Type, target: Type) {
|
||||
@ -6571,10 +6573,21 @@ 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;
|
||||
}
|
||||
|
||||
const key = source.id + "," + target.id;
|
||||
if (hasProperty(visited, key)) {
|
||||
return;
|
||||
}
|
||||
visited[key] = true;
|
||||
|
||||
if (depth === 0) {
|
||||
sourceStack = [];
|
||||
targetStack = [];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user