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
type.flags & TypeFlags.IndexedAccess ? isDistributive((type as IndexedAccessType).objectType) && isDistributive((type as IndexedAccessType).indexType) :
15344
-
type.flags & TypeFlags.Substitution ? isDistributive((type as SubstitutionType).substitute) :
15350
+
type.flags & TypeFlags.Substitution ? isDistributive((type as SubstitutionType).baseType) && isDistributive((type as SubstitutionType).constraint):
15345
15351
type.flags & TypeFlags.StringMapping ? isDistributive((type as StringMappingType).type) :
15346
15352
false;
15347
15353
}
@@ -15861,7 +15867,7 @@ namespace ts {
15861
15867
if (type.flags & TypeFlags.Substitution) {
15862
15868
if (!((type as SubstitutionType).objectFlags & ObjectFlags.IsGenericTypeComputed)) {
15863
15869
(type as SubstitutionType).objectFlags |= ObjectFlags.IsGenericTypeComputed |
15864
-
getGenericObjectFlags((type as SubstitutionType).substitute) | getGenericObjectFlags((type as SubstitutionType).baseType);
15870
+
getGenericObjectFlags((type as SubstitutionType).baseType) | getGenericObjectFlags((type as SubstitutionType).constraint);
15865
15871
}
15866
15872
return (type as SubstitutionType).objectFlags & ObjectFlags.IsGenericType;
15867
15873
}
@@ -17407,17 +17413,17 @@ namespace ts {
17407
17413
return getConditionalTypeInstantiation(type as ConditionalType, combineTypeMappers((type as ConditionalType).mapper, mapper), aliasSymbol, aliasTypeArguments);
17408
17414
}
17409
17415
if (flags & TypeFlags.Substitution) {
17410
-
const maybeVariable = instantiateType((type as SubstitutionType).baseType, mapper);
17411
-
if (maybeVariable.flags & TypeFlags.TypeVariable) {
17412
-
return getSubstitutionType(maybeVariable as TypeVariable, instantiateType((type as SubstitutionType).substitute, mapper));
17413
-
}
17414
-
else {
17415
-
const sub = instantiateType((type as SubstitutionType).substitute, mapper);
17416
-
if (sub.flags & TypeFlags.AnyOrUnknown || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) {
17417
-
return maybeVariable;
17418
-
}
17419
-
return sub;
17420
-
}
17416
+
const newBaseType = instantiateType((type as SubstitutionType).baseType, mapper);
17417
+
const newConstraint = instantiateType((type as SubstitutionType).constraint, mapper);
17418
+
// A substitution type originates in the true branch of a conditional type and can be resolved
17419
+
// to just the base type in the same cases as the conditional type resolves to its true branch
17420
+
// (because the base type is then known to satisfy the constraint).
17421
+
if (newConstraint.flags & TypeFlags.AnyOrUnknown ||
const t = isFreshLiteralType(type) ? (type as FreshableType).regularType :
18457
18463
getObjectFlags(type) & ObjectFlags.Reference ? (type as TypeReference).node ? createTypeReference((type as TypeReference).target, getTypeArguments(type as TypeReference)) : getSingleBaseForNonAugmentingSubtype(type) || type :
18458
18464
type.flags & TypeFlags.UnionOrIntersection ? getNormalizedUnionOrIntersectionType(type as UnionOrIntersectionType, writing) :
18459
-
type.flags & TypeFlags.Substitution ? writing ? (type as SubstitutionType).baseType : (type as SubstitutionType).substitute :
18465
+
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);
19548
+
if (result = isRelatedTo((source as SubstitutionType).baseType, (target as SubstitutionType).baseType, RecursionFlags.Both, /*reportErrors*/ false)) {
19549
+
if (result &= isRelatedTo((source as SubstitutionType).constraint, (target as SubstitutionType).constraint, RecursionFlags.Both, /*reportErrors*/ false)) {
19550
+
return result;
19551
+
}
19552
+
}
19543
19553
}
19544
19554
if (!(sourceFlags & TypeFlags.Object)) {
19545
19555
return Ternary.False;
@@ -22677,7 +22687,7 @@ namespace ts {
22677
22687
}
22678
22688
else if (source.flags & TypeFlags.Substitution) {
22679
22689
inferFromTypes((source as SubstitutionType).baseType, target);
22680
-
inferWithPriority((source as SubstitutionType).substitute, target, InferencePriority.SubstituteSource); // Make substitute inference at a lower priority
22690
+
inferWithPriority(getSubstitutionIntersection(source as SubstitutionType), target, InferencePriority.SubstituteSource); // Make substitute inference at a lower priority
0 commit comments