You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Optimize substitution type infrastructure
* Accept new baselines
* Preserve instantiated substitution types for type variables
* Restrictive type parameters should have no constraint
* Fix issues from top100 test run
* Accept new baselines
(tp.restrictiveInstantiation as TypeParameter).constraint = unknownType,
17046
+
(tp.restrictiveInstantiation as TypeParameter).constraint = noConstraintType,
17046
17047
tp.restrictiveInstantiation
17047
17048
);
17048
17049
}
@@ -17429,17 +17430,18 @@ namespace ts {
17429
17430
return getConditionalTypeInstantiation(type as ConditionalType, combineTypeMappers((type as ConditionalType).mapper, mapper), aliasSymbol, aliasTypeArguments);
17430
17431
}
17431
17432
if (flags & TypeFlags.Substitution) {
17432
-
const maybeVariable = instantiateType((type as SubstitutionType).baseType, mapper);
17433
-
if (maybeVariable.flags & TypeFlags.TypeVariable) {
17434
-
return getSubstitutionType(maybeVariable as TypeVariable, instantiateType((type as SubstitutionType).substitute, mapper));
17433
+
const newBaseType = instantiateType((type as SubstitutionType).baseType, mapper);
17434
+
const newConstraint = instantiateType((type as SubstitutionType).constraint, mapper);
17435
+
// A substitution type originates in the true branch of a conditional type and can be resolved
17436
+
// to just the base type in the same cases as the conditional type resolves to its true branch
17437
+
// (because the base type is then known to satisfy the constraint).
17438
+
if (newBaseType.flags & TypeFlags.TypeVariable && isGenericType(newConstraint)) {
const t = isFreshLiteralType(type) ? (type as FreshableType).regularType :
18479
18481
getObjectFlags(type) & ObjectFlags.Reference ? (type as TypeReference).node ? createTypeReference((type as TypeReference).target, getTypeArguments(type as TypeReference)) : getSingleBaseForNonAugmentingSubtype(type) || type :
18480
18482
type.flags & TypeFlags.UnionOrIntersection ? getNormalizedUnionOrIntersectionType(type as UnionOrIntersectionType, writing) :
18481
-
type.flags & TypeFlags.Substitution ? writing ? (type as SubstitutionType).baseType : (type as SubstitutionType).substitute :
18483
+
type.flags & TypeFlags.Substitution ? writing ? (type as SubstitutionType).baseType : getSubstitutionIntersection(type as SubstitutionType) :
return isRelatedTo((source as SubstitutionType).substitute, (target as SubstitutionType).substitute, RecursionFlags.Both, /*reportErrors*/ false);
19566
+
if (result = isRelatedTo((source as SubstitutionType).baseType, (target as SubstitutionType).baseType, RecursionFlags.Both, /*reportErrors*/ false)) {
19567
+
if (result &= isRelatedTo((source as SubstitutionType).constraint, (target as SubstitutionType).constraint, RecursionFlags.Both, /*reportErrors*/ false)) {
19568
+
return result;
19569
+
}
19570
+
}
19565
19571
}
19566
19572
if (!(sourceFlags & TypeFlags.Object)) {
19567
19573
return Ternary.False;
@@ -22699,7 +22705,7 @@ namespace ts {
22699
22705
}
22700
22706
else if (source.flags & TypeFlags.Substitution) {
22701
22707
inferFromTypes((source as SubstitutionType).baseType, target);
22702
-
inferWithPriority((source as SubstitutionType).substitute, target, InferencePriority.SubstituteSource); // Make substitute inference at a lower priority
22708
+
inferWithPriority(getSubstitutionIntersection(source as SubstitutionType), target, InferencePriority.SubstituteSource); // Make substitute inference at a lower priority
0 commit comments