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

Literal Types

Complex Type Flags

Object and Structure Types

Advanced Types

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