@@ -9211,22 +9211,6 @@ namespace ts {
9211
9211
return maybeTypeOfKind(type, TypeFlags.InstantiableNonPrimitive | TypeFlags.Index);
9212
9212
}
9213
9213
9214
- // Return true if the given type is a non-generic object type with a string index signature and no
9215
- // other members.
9216
- function isStringIndexOnlyType(type: Type): boolean {
9217
- if (type.flags & TypeFlags.Object && !isGenericMappedType(type)) {
9218
- const t = resolveStructuredTypeMembers(<ObjectType>type);
9219
- return t.properties.length === 0 &&
9220
- t.callSignatures.length === 0 && t.constructSignatures.length === 0 &&
9221
- !!t.stringIndexInfo && !t.numberIndexInfo;
9222
- }
9223
- return false;
9224
- }
9225
-
9226
- function isMappedTypeToNever(type: Type): boolean {
9227
- return !!(getObjectFlags(type) & ObjectFlags.Mapped) && getTemplateTypeFromMappedType(type as MappedType) === neverType;
9228
- }
9229
-
9230
9214
function getSimplifiedType(type: Type): Type {
9231
9215
return type.flags & TypeFlags.IndexedAccess ? getSimplifiedIndexedAccessType(<IndexedAccessType>type) : type;
9232
9216
}
@@ -9241,35 +9225,11 @@ namespace ts {
9241
9225
// We recursively simplify the object type as it may in turn be an indexed access type. For example, with
9242
9226
// '{ [P in T]: { [Q in U]: number } }[T][U]' we want to first simplify the inner indexed access type.
9243
9227
const objectType = getSimplifiedType(type.objectType);
9244
- if (objectType.flags & TypeFlags.Intersection && isGenericObjectType(objectType)) {
9245
- // Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or
9246
- // more object types with only a string index signature, e.g. '(U & V & { [x: string]: D })[K]', return a
9247
- // transformed type of the form '(U & V)[K] | D'. This allows us to properly reason about higher order indexed
9248
- // access types with default property values as expressed by D.
9249
- if (some((<IntersectionType>objectType).types, isStringIndexOnlyType)) {
9250
- const regularTypes: Type[] = [];
9251
- const stringIndexTypes: Type[] = [];
9252
- for (const t of (<IntersectionType>objectType).types) {
9253
- if (isStringIndexOnlyType(t)) {
9254
- stringIndexTypes.push(getIndexTypeOfType(t, IndexKind.String)!);
9255
- }
9256
- else {
9257
- regularTypes.push(t);
9258
- }
9259
- }
9260
- return type.simplified = getUnionType([
9261
- getSimplifiedType(getIndexedAccessType(getIntersectionType(regularTypes), type.indexType)),
9262
- getIntersectionType(stringIndexTypes)
9263
- ]);
9264
- }
9265
- // Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or
9266
- // more mapped types with a template type `never`, '(U & V & { [P in T]: never })[K]', return a
9267
- // transformed type that removes the never-mapped type: '(U & V)[K]'. This mirrors what would happen
9268
- // eventually anyway, but it easier to reason about.
9269
- if (some((<IntersectionType>objectType).types, isMappedTypeToNever)) {
9270
- const nonNeverTypes = filter((<IntersectionType>objectType).types, t => !isMappedTypeToNever(t));
9271
- return type.simplified = getSimplifiedType(getIndexedAccessType(getIntersectionType(nonNeverTypes), type.indexType));
9272
- }
9228
+ if (objectType.flags & TypeFlags.Union) {
9229
+ return type.simplified = mapType(objectType, t => getIndexedAccessType(t, type.indexType));
9230
+ }
9231
+ if (objectType.flags & TypeFlags.Intersection) {
9232
+ return type.simplified = getIntersectionType(map((objectType as IntersectionType).types, t => getIndexedAccessType(t, type.indexType)));
9273
9233
}
9274
9234
// If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper
9275
9235
// that substitutes the index type for P. For example, for an index access { [P in K]: Box<T[P]> }[X], we
@@ -9297,12 +9257,6 @@ namespace ts {
9297
9257
if (objectType === wildcardType || indexType === wildcardType) {
9298
9258
return wildcardType;
9299
9259
}
9300
- if (objectType.flags & TypeFlags.Union) {
9301
- return mapType(objectType, t => getIndexedAccessType(t, indexType));
9302
- }
9303
- if (objectType.flags & TypeFlags.Intersection) {
9304
- return getIntersectionType(map((objectType as IntersectionType).types, t => getIndexedAccessType(t, indexType)));
9305
- }
9306
9260
// If the index type is generic, or if the object type is generic and doesn't originate in an expression,
9307
9261
// we are performing a higher-order index access where we cannot meaningfully access the properties of the
9308
9262
// object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in
0 commit comments