Always infer between distinct type references to same target

This commit is contained in:
Anders Hejlsberg 2019-07-20 14:33:35 -07:00
parent 6b29060111
commit 2541a5d0ff

View file

@ -15958,9 +15958,14 @@ namespace ts {
}
}
function isTypeReferenceToSameTarget(source: Type, target: Type) {
return !!(getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference &&
(<TypeReference>source).target === (<TypeReference>target).target);
}
function typeIdenticalToSomeType(type: Type, types: Type[]): boolean {
for (const t of types) {
if (isTypeIdenticalTo(t, type)) {
if (t === type || !isTypeReferenceToSameTarget(t, type) && isTypeIdenticalTo(t, type)) {
return true;
}
}