Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 39 additions & 28 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5152,6 +5152,9 @@ namespace ts {
export interface EnumType extends Type {
}

// Types included in TypeFlags.ObjectFlagsType have an objectFlags property. Some ObjectFlags
// are specific to certain types and reuse the same bit position. Those ObjectFlags require a check
// for a certain TypeFlags value to determine their meaning.
export const enum ObjectFlags {
Class = 1 << 0, // Class
Interface = 1 << 1, // Interface
Expand All @@ -5163,51 +5166,59 @@ namespace ts {
ObjectLiteral = 1 << 7, // Originates in an object literal
EvolvingArray = 1 << 8, // Evolving array type
ObjectLiteralPatternWithComputedProperties = 1 << 9, // Object literal pattern with computed properties
ContainsSpread = 1 << 10, // Object literal contains spread operation
ReverseMapped = 1 << 11, // Object contains a property from a reverse-mapped type
JsxAttributes = 1 << 12, // Jsx attributes type
MarkerType = 1 << 13, // Marker type used for variance probing
JSLiteral = 1 << 14, // Object type declared in JS - disables errors on read/write of nonexisting members
FreshLiteral = 1 << 15, // Fresh object literal
ArrayLiteral = 1 << 16, // Originates in an array literal
ObjectRestType = 1 << 17, // Originates in object rest declaration
ReverseMapped = 1 << 10, // Object contains a property from a reverse-mapped type
JsxAttributes = 1 << 11, // Jsx attributes type
MarkerType = 1 << 12, // Marker type used for variance probing
JSLiteral = 1 << 13, // Object type declared in JS - disables errors on read/write of nonexisting members
FreshLiteral = 1 << 14, // Fresh object literal
ArrayLiteral = 1 << 15, // Originates in an array literal
/* @internal */
PrimitiveUnion = 1 << 18, // Union of only primitive types
PrimitiveUnion = 1 << 16, // Union of only primitive types
/* @internal */
ContainsWideningType = 1 << 19, // Type is or contains undefined or null widening type
ContainsWideningType = 1 << 17, // Type is or contains undefined or null widening type
/* @internal */
ContainsObjectOrArrayLiteral = 1 << 20, // Type is or contains object literal type
ContainsObjectOrArrayLiteral = 1 << 18, // Type is or contains object literal type
/* @internal */
NonInferrableType = 1 << 21, // Type is or contains anyFunctionType or silentNeverType
NonInferrableType = 1 << 19, // Type is or contains anyFunctionType or silentNeverType
/* @internal */
IsGenericObjectTypeComputed = 1 << 22, // IsGenericObjectType flag has been computed
/* @internal */
IsGenericObjectType = 1 << 23, // Union or intersection contains generic object type
CouldContainTypeVariablesComputed = 1 << 20, // CouldContainTypeVariables flag has been computed
/* @internal */
IsGenericIndexTypeComputed = 1 << 24, // IsGenericIndexType flag has been computed
CouldContainTypeVariables = 1 << 21, // Type could contain a type variable

ClassOrInterface = Class | Interface,
/* @internal */
IsGenericIndexType = 1 << 25, // Union or intersection contains generic index type
RequiresWidening = ContainsWideningType | ContainsObjectOrArrayLiteral,
/* @internal */
CouldContainTypeVariablesComputed = 1 << 26, // CouldContainTypeVariables flag has been computed
PropagatingFlags = ContainsWideningType | ContainsObjectOrArrayLiteral | NonInferrableType,
// Object flags that uniquely identify the kind of ObjectType
/* @internal */
CouldContainTypeVariables = 1 << 27, // Type could contain a type variable
ObjectTypeKindMask = ClassOrInterface | Reference | Tuple | Anonymous | Mapped | ReverseMapped | EvolvingArray,

// Flags that require TypeFlags.Object
ContainsSpread = 1 << 22, // Object literal contains spread operation
ObjectRestType = 1 << 23, // Originates in object rest declaration
/* @internal */
ContainsIntersections = 1 << 28, // Union contains intersections
IsClassInstanceClone = 1 << 24, // Type is a clone of a class instance type

// Flags that require TypeFlags.UnionOrIntersection
/* @internal */
IsNeverIntersectionComputed = 1 << 28, // IsNeverLike flag has been computed
IsGenericObjectTypeComputed = 1 << 22, // IsGenericObjectType flag has been computed
/* @internal */
IsNeverIntersection = 1 << 29, // Intersection reduces to never
IsGenericObjectType = 1 << 23, // Union or intersection contains generic object type
/* @internal */
IsClassInstanceClone = 1 << 30, // Type is a clone of a class instance type
ClassOrInterface = Class | Interface,
IsGenericIndexTypeComputed = 1 << 24, // IsGenericIndexType flag has been computed
/* @internal */
RequiresWidening = ContainsWideningType | ContainsObjectOrArrayLiteral,
IsGenericIndexType = 1 << 25, // Union or intersection contains generic index type

// Flags that require TypeFlags.Union
/* @internal */
PropagatingFlags = ContainsWideningType | ContainsObjectOrArrayLiteral | NonInferrableType,
ContainsIntersections = 1 << 26, // Union contains intersections

// Object flags that uniquely identify the kind of ObjectType
// Flags that require TypeFlags.Intersection
/* @internal */
ObjectTypeKindMask = ClassOrInterface | Reference | Tuple | Anonymous | Mapped | ReverseMapped | EvolvingArray,
IsNeverIntersectionComputed = 1 << 26, // IsNeverLike flag has been computed
/* @internal */
IsNeverIntersection = 1 << 27, // Intersection reduces to never
}

/* @internal */
Expand Down
16 changes: 8 additions & 8 deletions tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2559,15 +2559,15 @@ declare namespace ts {
ObjectLiteral = 128,
EvolvingArray = 256,
ObjectLiteralPatternWithComputedProperties = 512,
ContainsSpread = 1024,
ReverseMapped = 2048,
JsxAttributes = 4096,
MarkerType = 8192,
JSLiteral = 16384,
FreshLiteral = 32768,
ArrayLiteral = 65536,
ObjectRestType = 131072,
ReverseMapped = 1024,
JsxAttributes = 2048,
MarkerType = 4096,
JSLiteral = 8192,
FreshLiteral = 16384,
ArrayLiteral = 32768,
ClassOrInterface = 3,
ContainsSpread = 4194304,
ObjectRestType = 8388608,
}
export interface ObjectType extends Type {
objectFlags: ObjectFlags;
Expand Down
16 changes: 8 additions & 8 deletions tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2559,15 +2559,15 @@ declare namespace ts {
ObjectLiteral = 128,
EvolvingArray = 256,
ObjectLiteralPatternWithComputedProperties = 512,
ContainsSpread = 1024,
ReverseMapped = 2048,
JsxAttributes = 4096,
MarkerType = 8192,
JSLiteral = 16384,
FreshLiteral = 32768,
ArrayLiteral = 65536,
ObjectRestType = 131072,
ReverseMapped = 1024,
JsxAttributes = 2048,
MarkerType = 4096,
JSLiteral = 8192,
FreshLiteral = 16384,
ArrayLiteral = 32768,
ClassOrInterface = 3,
ContainsSpread = 4194304,
ObjectRestType = 8388608,
}
export interface ObjectType extends Type {
objectFlags: ObjectFlags;
Expand Down