Skip to content

Commit 8f193b4

Browse files
committed
Free up one bit in TypeFlags
1 parent 07a696f commit 8f193b4

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19934,7 +19934,7 @@ namespace ts {
1993419934
// Return true if type might be of the given kind. A union or intersection type might be of a given
1993519935
// kind if at least one constituent type is of the given kind.
1993619936
function maybeTypeOfKind(type: Type, kind: TypeFlags): boolean {
19937-
if (type.flags & kind || kind & TypeFlags.GenericMappedType && isGenericMappedType(type)) {
19937+
if (type.flags & kind & ~TypeFlags.GenericMappedType || kind & TypeFlags.GenericMappedType && isGenericMappedType(type)) {
1993819938
return true;
1993919939
}
1994019940
if (type.flags & TypeFlags.UnionOrIntersection) {

src/compiler/types.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3687,19 +3687,17 @@ namespace ts {
36873687
IndexedAccess = 1 << 20, // T[K]
36883688
Conditional = 1 << 21, // T extends U ? X : Y
36893689
Substitution = 1 << 22, // Type parameter substitution
3690+
NonPrimitive = 1 << 23, // intrinsic object type
36903691
/* @internal */
3691-
FreshLiteral = 1 << 23, // Fresh literal or unique type
3692+
FreshLiteral = 1 << 24, // Fresh literal or unique type
36923693
/* @internal */
3693-
ContainsWideningType = 1 << 24, // Type is or contains undefined or null widening type
3694+
UnionOfUnitTypes = 1 << 25, // Type is union of unit types
36943695
/* @internal */
3695-
ContainsObjectLiteral = 1 << 25, // Type is or contains object literal type
3696+
ContainsWideningType = 1 << 26, // Type is or contains undefined or null widening type
36963697
/* @internal */
3697-
ContainsAnyFunctionType = 1 << 26, // Type is or contains the anyFunctionType
3698-
NonPrimitive = 1 << 27, // intrinsic object type
3698+
ContainsObjectLiteral = 1 << 27, // Type is or contains object literal type
36993699
/* @internal */
3700-
UnionOfUnitTypes = 1 << 28, // Type is union of unit types
3701-
/* @internal */
3702-
GenericMappedType = 1 << 29, // Flag used by maybeTypeOfKind
3700+
ContainsAnyFunctionType = 1 << 28, // Type is or contains the anyFunctionType
37033701

37043702
/* @internal */
37053703
Nullable = Undefined | Null,
@@ -3749,7 +3747,10 @@ namespace ts {
37493747
/* @internal */
37503748
EmptyObject = ContainsAnyFunctionType,
37513749
/* @internal */
3752-
ConstructionFlags = NonWideningType | Wildcard | EmptyObject
3750+
ConstructionFlags = NonWideningType | Wildcard | EmptyObject,
3751+
// The following flag is used for different purposes by maybeTypeOfKind
3752+
/* @internal */
3753+
GenericMappedType = ContainsWideningType
37533754
}
37543755

37553756
export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;

0 commit comments

Comments
 (0)