@@ -12498,11 +12498,25 @@ namespace ts {
12498
12498
}
12499
12499
12500
12500
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);
12502
12509
}
12503
12510
12504
12511
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));
12506
12520
}
12507
12521
12508
12522
function isThisTypeParameter(type: Type): boolean {
@@ -12726,7 +12740,7 @@ namespace ts {
12726
12740
if (checkType === wildcardType || extendsType === wildcardType) {
12727
12741
return wildcardType;
12728
12742
}
12729
- const checkTypeInstantiable = maybeTypeOfKind (checkType, TypeFlags.Instantiable | TypeFlags.GenericMappedType );
12743
+ const checkTypeInstantiable = isGenericObjectType (checkType) || isGenericIndexType(checkType );
12730
12744
let combinedMapper: TypeMapper | undefined;
12731
12745
if (root.inferTypeParameters) {
12732
12746
const context = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, InferenceFlags.None);
@@ -12745,7 +12759,7 @@ namespace ts {
12745
12759
// Instantiate the extends type including inferences for 'infer T' type parameters
12746
12760
const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
12747
12761
// 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 )) {
12749
12763
if (inferredExtendsType.flags & TypeFlags.AnyOrUnknown) {
12750
12764
return instantiateType(root.trueType, combinedMapper || mapper);
12751
12765
}
@@ -27037,7 +27051,7 @@ namespace ts {
27037
27051
// Return true if type might be of the given kind. A union or intersection type might be of a given
27038
27052
// kind if at least one constituent type is of the given kind.
27039
27053
function maybeTypeOfKind(type: Type, kind: TypeFlags): boolean {
27040
- if (type.flags & kind & ~TypeFlags.GenericMappedType || kind & TypeFlags.GenericMappedType && isGenericMappedType(type) ) {
27054
+ if (type.flags & kind) {
27041
27055
return true;
27042
27056
}
27043
27057
if (type.flags & TypeFlags.UnionOrIntersection) {
0 commit comments