@@ -12498,11 +12498,25 @@ namespace ts {
1249812498 }
1249912499
1250012500 function isGenericObjectType(type: Type): boolean {
12501- return maybeTypeOfKind(type, TypeFlags.InstantiableNonPrimitive | TypeFlags.GenericMappedType);
12501+ if (type.flags & TypeFlags.UnionOrIntersection) {
12502+ if (!((<UnionOrIntersectionType>type).objectFlags & ObjectFlags.IsGenericObjectTypeComputed)) {
12503+ (<UnionOrIntersectionType>type).objectFlags |= ObjectFlags.IsGenericObjectTypeComputed |
12504+ (some((<UnionOrIntersectionType>type).types, isGenericObjectType) ? ObjectFlags.IsGenericObjectType : 0);
12505+ }
12506+ return !!((<UnionOrIntersectionType>type).objectFlags & ObjectFlags.IsGenericObjectType);
12507+ }
12508+ return !!(type.flags & TypeFlags.InstantiableNonPrimitive) || isGenericMappedType(type);
1250212509 }
1250312510
1250412511 function isGenericIndexType(type: Type): boolean {
12505- return maybeTypeOfKind(type, TypeFlags.InstantiableNonPrimitive | TypeFlags.Index);
12512+ if (type.flags & TypeFlags.UnionOrIntersection) {
12513+ if (!((<UnionOrIntersectionType>type).objectFlags & ObjectFlags.IsGenericIndexTypeComputed)) {
12514+ (<UnionOrIntersectionType>type).objectFlags |= ObjectFlags.IsGenericIndexTypeComputed |
12515+ (some((<UnionOrIntersectionType>type).types, isGenericIndexType) ? ObjectFlags.IsGenericIndexType : 0);
12516+ }
12517+ return !!((<UnionOrIntersectionType>type).objectFlags & ObjectFlags.IsGenericIndexType);
12518+ }
12519+ return !!(type.flags & (TypeFlags.InstantiableNonPrimitive | TypeFlags.Index));
1250612520 }
1250712521
1250812522 function isThisTypeParameter(type: Type): boolean {
@@ -12726,7 +12740,7 @@ namespace ts {
1272612740 if (checkType === wildcardType || extendsType === wildcardType) {
1272712741 return wildcardType;
1272812742 }
12729- const checkTypeInstantiable = maybeTypeOfKind (checkType, TypeFlags.Instantiable | TypeFlags.GenericMappedType );
12743+ const checkTypeInstantiable = isGenericObjectType (checkType) || isGenericIndexType(checkType );
1273012744 let combinedMapper: TypeMapper | undefined;
1273112745 if (root.inferTypeParameters) {
1273212746 const context = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, InferenceFlags.None);
@@ -12745,7 +12759,7 @@ namespace ts {
1274512759 // Instantiate the extends type including inferences for 'infer T' type parameters
1274612760 const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
1274712761 // We attempt to resolve the conditional type only when the check and extends types are non-generic
12748- if (!checkTypeInstantiable && !maybeTypeOfKind (inferredExtendsType, TypeFlags.Instantiable | TypeFlags.GenericMappedType )) {
12762+ if (!checkTypeInstantiable && !isGenericObjectType (inferredExtendsType) && !isGenericIndexType(inferredExtendsType )) {
1274912763 if (inferredExtendsType.flags & TypeFlags.AnyOrUnknown) {
1275012764 return instantiateType(root.trueType, combinedMapper || mapper);
1275112765 }
@@ -27037,7 +27051,7 @@ namespace ts {
2703727051 // Return true if type might be of the given kind. A union or intersection type might be of a given
2703827052 // kind if at least one constituent type is of the given kind.
2703927053 function maybeTypeOfKind(type: Type, kind: TypeFlags): boolean {
27040- if (type.flags & kind & ~TypeFlags.GenericMappedType || kind & TypeFlags.GenericMappedType && isGenericMappedType(type) ) {
27054+ if (type.flags & kind) {
2704127055 return true;
2704227056 }
2704327057 if (type.flags & TypeFlags.UnionOrIntersection) {
0 commit comments