@@ -27130,37 +27130,16 @@ namespace ts {
2713027130 }
2713127131
2713227132 function getTypeOfPropertyOfContextualType(type: Type, name: __String, nameType?: Type) {
27133- return mapType(type, (t): Type | undefined => {
27134- if (t.flags & TypeFlags.Intersection) {
27135- const intersection = t as IntersectionType;
27136- let newTypes = mapDefined(intersection.types, getTypeOfConcretePropertyOfContextualType);
27137- if (newTypes.length > 0) {
27138- return getIntersectionType(newTypes);
27139- }
27140- newTypes = mapDefined(intersection.types, getTypeOfApplicableIndexInfoOfContextualType);
27141- if (newTypes.length > 0) {
27142- return getIntersectionType(newTypes);
27143- }
27144- return undefined;
27145- }
27146- const concretePropertyType = getTypeOfConcretePropertyOfContextualType(t);
27147- if (concretePropertyType) {
27148- return concretePropertyType;
27149- }
27150- return getTypeOfApplicableIndexInfoOfContextualType(t);
27151- }, /*noReductions*/ true);
27152-
27153- function getTypeOfConcretePropertyOfContextualType(t: Type) {
27133+ return mapType(type, t => {
2715427134 if (isGenericMappedType(t) && !t.declaration.nameType) {
2715527135 const constraint = getConstraintTypeFromMappedType(t);
2715627136 const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
2715727137 const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
2715827138 if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
2715927139 return substituteIndexedMappedType(t, propertyNameType);
2716027140 }
27161- return undefined;
2716227141 }
27163- if (t.flags & TypeFlags.StructuredType) {
27142+ else if (t.flags & TypeFlags.StructuredType) {
2716427143 const prop = getPropertyOfType(t, name);
2716527144 if (prop) {
2716627145 return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
@@ -27171,15 +27150,10 @@ namespace ts {
2717127150 return restType;
2717227151 }
2717327152 }
27153+ return findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(unescapeLeadingUnderscores(name)))?.type;
2717427154 }
2717527155 return undefined;
27176- }
27177- function getTypeOfApplicableIndexInfoOfContextualType(t: Type) {
27178- if (!(t.flags & TypeFlags.StructuredType)) {
27179- return undefined;
27180- }
27181- return findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(unescapeLeadingUnderscores(name)))?.type;
27182- }
27156+ }, /*noReductions*/ true);
2718327157 }
2718427158
2718527159 // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of
0 commit comments