Free up one bit in TypeFlags

This commit is contained in:
Anders Hejlsberg 2018-05-26 08:29:30 -07:00
parent 07a696f785
commit 8f193b40ee
2 changed files with 11 additions and 10 deletions

View file

@ -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) {

View file

@ -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;