Skip to main content
The TypeFlags enum contains bit flags that classify types in the TypeScript type system. Every Type object has a flags property containing a combination of these flags.

Primitive Type Flags

Basic Types

FlagDescription
Anyany type
Unknownunknown type
Undefinedundefined type
Nullnull type
Voidvoid type
Stringstring type
Numbernumber type
BigIntbigint type
Booleanboolean type
ESSymbolsymbol type
Nevernever type

Literal Types

FlagDescription
StringLiteralString literal type (e.g., "hello")
NumberLiteralNumber literal type (e.g., 42)
BigIntLiteralBigInt literal type (e.g., 100n)
BooleanLiteralBoolean literal type (true or false)
UniqueESSymbolUnique symbol type
EnumLiteralEnum member literal
EnumComputed enum member value

Complex Type Flags

Object and Structure Types

FlagDescription
ObjectObject type
NonPrimitiveobject intrinsic type
TypeParameterType parameter
UnionUnion type (`TU`)
IntersectionIntersection type (T & U)

Advanced Types

FlagDescription
Indexkeyof T type
IndexedAccessT[K] type
ConditionalConditional type (T extends U ? X : Y)
SubstitutionType parameter substitution
TemplateLiteralTemplate literal type
StringMappingString mapping type (e.g., Uppercase<T>)

Composite Flags

The enum includes composite flags for common type combinations:

Nullable Types

Represents types that are undefined or null.

Literal Types

All literal types.

Unit Types

Types with a single possible value.

String-like Types

All types that behave like strings.

Number-like Types

All types that behave like numbers.

Boolean-like Types

Boolean and boolean literal types.

Primitive Types

All primitive types.

Structured Types

Types with structure.

Type Variables

Types that can be instantiated.

Instantiable Types

Types that need instantiation.

Union and Intersection

Composite types.

Structured or Instantiable

Complex types requiring special handling.

Specialized Composite Flags

Possibly Falsy

Types that can be falsy in JavaScript.

Narrowable Types

Types where narrowing actually narrows (excludes null, undefined, void, and never).

Definitely Non-Nullable

Types that cannot be null or undefined.

Using TypeFlags

Checking Type Flags

Testing Multiple Flags

Type Guards

Combine flags with type narrowing:

Common Patterns

Checking for Nullable Types

Distinguishing Primitives

Working with Literals

Handling Unions and Intersections

Internal Flags

Some flags are marked as internal and used by the compiler:
These are typically used during type checking and type construction.

See Also