@@ -27130,37 +27130,16 @@ namespace ts {
27130
27130
}
27131
27131
27132
27132
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 => {
27154
27134
if (isGenericMappedType(t) && !t.declaration.nameType) {
27155
27135
const constraint = getConstraintTypeFromMappedType(t);
27156
27136
const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
27157
27137
const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
27158
27138
if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
27159
27139
return substituteIndexedMappedType(t, propertyNameType);
27160
27140
}
27161
- return undefined;
27162
27141
}
27163
- if (t.flags & TypeFlags.StructuredType) {
27142
+ else if (t.flags & TypeFlags.StructuredType) {
27164
27143
const prop = getPropertyOfType(t, name);
27165
27144
if (prop) {
27166
27145
return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
@@ -27171,15 +27150,10 @@ namespace ts {
27171
27150
return restType;
27172
27151
}
27173
27152
}
27153
+ return findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(unescapeLeadingUnderscores(name)))?.type;
27174
27154
}
27175
27155
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);
27183
27157
}
27184
27158
27185
27159
// In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of
0 commit comments