diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ebabed81818..322db076879 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19934,7 +19934,7 @@ namespace ts { // Return true if type might be of the given kind. A union or intersection type might be of a given // kind if at least one constituent type is of the given kind. function maybeTypeOfKind(type: Type, kind: TypeFlags): boolean { - if (type.flags & kind || kind & TypeFlags.GenericMappedType && isGenericMappedType(type)) { + if (type.flags & kind & ~TypeFlags.GenericMappedType || kind & TypeFlags.GenericMappedType && isGenericMappedType(type)) { return true; } if (type.flags & TypeFlags.UnionOrIntersection) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a3cdb32df07..daccfd28282 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3687,19 +3687,17 @@ namespace ts { IndexedAccess = 1 << 20, // T[K] Conditional = 1 << 21, // T extends U ? X : Y Substitution = 1 << 22, // Type parameter substitution + NonPrimitive = 1 << 23, // intrinsic object type /* @internal */ - FreshLiteral = 1 << 23, // Fresh literal or unique type + FreshLiteral = 1 << 24, // Fresh literal or unique type /* @internal */ - ContainsWideningType = 1 << 24, // Type is or contains undefined or null widening type + UnionOfUnitTypes = 1 << 25, // Type is union of unit types /* @internal */ - ContainsObjectLiteral = 1 << 25, // Type is or contains object literal type + ContainsWideningType = 1 << 26, // Type is or contains undefined or null widening type /* @internal */ - ContainsAnyFunctionType = 1 << 26, // Type is or contains the anyFunctionType - NonPrimitive = 1 << 27, // intrinsic object type + ContainsObjectLiteral = 1 << 27, // Type is or contains object literal type /* @internal */ - UnionOfUnitTypes = 1 << 28, // Type is union of unit types - /* @internal */ - GenericMappedType = 1 << 29, // Flag used by maybeTypeOfKind + ContainsAnyFunctionType = 1 << 28, // Type is or contains the anyFunctionType /* @internal */ Nullable = Undefined | Null, @@ -3749,7 +3747,10 @@ namespace ts { /* @internal */ EmptyObject = ContainsAnyFunctionType, /* @internal */ - ConstructionFlags = NonWideningType | Wildcard | EmptyObject + ConstructionFlags = NonWideningType | Wildcard | EmptyObject, + // The following flag is used for different purposes by maybeTypeOfKind + /* @internal */ + GenericMappedType = ContainsWideningType } export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;