Skip to content

Commit a3d23d3

Browse files
authored
Fix conditional type constraint exploration + signature relations (#47341)
1 parent 363e3a7 commit a3d23d3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/compiler/checker.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -19292,7 +19292,7 @@ namespace ts {
1929219292
else {
1929319293
// conditionals aren't related to one another via distributive constraint as it is much too inaccurate and allows way
1929419294
// more assignments than are desirable (since it maps the source check type to its constraint, it loses information)
19295-
const distributiveConstraint = getConstraintOfDistributiveConditionalType(source as ConditionalType);
19295+
const distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source as ConditionalType) : undefined;
1929619296
if (distributiveConstraint) {
1929719297
if (result = isRelatedTo(distributiveConstraint, target, RecursionFlags.Source, reportErrors)) {
1929819298
resetErrorInfo(saveErrorInfo);
@@ -19920,7 +19920,8 @@ namespace ts {
1992019920
const incompatibleReporter = kind === SignatureKind.Construct ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
1992119921
const sourceObjectFlags = getObjectFlags(source);
1992219922
const targetObjectFlags = getObjectFlags(target);
19923-
if (sourceObjectFlags & ObjectFlags.Instantiated && targetObjectFlags & ObjectFlags.Instantiated && source.symbol === target.symbol) {
19923+
if (sourceObjectFlags & ObjectFlags.Instantiated && targetObjectFlags & ObjectFlags.Instantiated && source.symbol === target.symbol ||
19924+
sourceObjectFlags & ObjectFlags.Reference && targetObjectFlags & ObjectFlags.Reference && (source as TypeReference).target === (target as TypeReference).target) {
1992419925
// We have instantiations of the same anonymous type (which typically will be the type of a
1992519926
// method). Simply do a pairwise comparison of the signatures in the two signature lists instead
1992619927
// of the much more expensive N * M comparison matrix we explore below. We erase type parameters

0 commit comments

Comments
 (0)