@@ -12458,11 +12458,25 @@ namespace ts {
1245812458 }
1245912459
1246012460 function isGenericObjectType(type: Type): boolean {
12461- return maybeTypeOfKind(type, TypeFlags.InstantiableNonPrimitive | TypeFlags.GenericMappedType);
12461+ if (type.flags & TypeFlags.UnionOrIntersection) {
12462+ if (!((<UnionOrIntersectionType>type).objectFlags & ObjectFlags.IsGenericObjectTypeComputed)) {
12463+ (<UnionOrIntersectionType>type).objectFlags |= ObjectFlags.IsGenericObjectTypeComputed |
12464+ (some((<UnionOrIntersectionType>type).types, isGenericObjectType) ? ObjectFlags.IsGenericObjectType : 0);
12465+ }
12466+ return !!((<UnionOrIntersectionType>type).objectFlags & ObjectFlags.IsGenericObjectType);
12467+ }
12468+ return !!(type.flags & TypeFlags.InstantiableNonPrimitive) || isGenericMappedType(type);
1246212469 }
1246312470
1246412471 function isGenericIndexType(type: Type): boolean {
12465- return maybeTypeOfKind(type, TypeFlags.InstantiableNonPrimitive | TypeFlags.Index);
12472+ if (type.flags & TypeFlags.UnionOrIntersection) {
12473+ if (!((<UnionOrIntersectionType>type).objectFlags & ObjectFlags.IsGenericIndexTypeComputed)) {
12474+ (<UnionOrIntersectionType>type).objectFlags |= ObjectFlags.IsGenericIndexTypeComputed |
12475+ (some((<UnionOrIntersectionType>type).types, isGenericIndexType) ? ObjectFlags.IsGenericIndexType : 0);
12476+ }
12477+ return !!((<UnionOrIntersectionType>type).objectFlags & ObjectFlags.IsGenericIndexType);
12478+ }
12479+ return !!(type.flags & (TypeFlags.InstantiableNonPrimitive | TypeFlags.Index));
1246612480 }
1246712481
1246812482 function isThisTypeParameter(type: Type): boolean {
@@ -12686,7 +12700,7 @@ namespace ts {
1268612700 if (checkType === wildcardType || extendsType === wildcardType) {
1268712701 return wildcardType;
1268812702 }
12689- const checkTypeInstantiable = maybeTypeOfKind (checkType, TypeFlags.Instantiable | TypeFlags.GenericMappedType );
12703+ const checkTypeInstantiable = isGenericObjectType (checkType) || isGenericIndexType(checkType );
1269012704 let combinedMapper: TypeMapper | undefined;
1269112705 if (root.inferTypeParameters) {
1269212706 const context = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, InferenceFlags.None);
@@ -12705,7 +12719,7 @@ namespace ts {
1270512719 // Instantiate the extends type including inferences for 'infer T' type parameters
1270612720 const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
1270712721 // We attempt to resolve the conditional type only when the check and extends types are non-generic
12708- if (!checkTypeInstantiable && !maybeTypeOfKind (inferredExtendsType, TypeFlags.Instantiable | TypeFlags.GenericMappedType )) {
12722+ if (!checkTypeInstantiable && !isGenericObjectType (inferredExtendsType) && !isGenericIndexType(inferredExtendsType )) {
1270912723 if (inferredExtendsType.flags & TypeFlags.AnyOrUnknown) {
1271012724 return instantiateType(root.trueType, combinedMapper || mapper);
1271112725 }
@@ -26992,7 +27006,7 @@ namespace ts {
2699227006 // Return true if type might be of the given kind. A union or intersection type might be of a given
2699327007 // kind if at least one constituent type is of the given kind.
2699427008 function maybeTypeOfKind(type: Type, kind: TypeFlags): boolean {
26995- if (type.flags & kind & ~TypeFlags.GenericMappedType || kind & TypeFlags.GenericMappedType && isGenericMappedType(type) ) {
27009+ if (type.flags & kind) {
2699627010 return true;
2699727011 }
2699827012 if (type.flags & TypeFlags.UnionOrIntersection) {
0 commit comments