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
undefined or null.
Literal Types
Unit Types
String-like Types
Number-like Types
Boolean-like Types
Primitive Types
Structured Types
Type Variables
Instantiable Types
Union and Intersection
Structured or Instantiable
Specialized Composite Flags
Possibly Falsy
Narrowable Types
null, undefined, void, and never).
Definitely Non-Nullable
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:See Also
- Node Types - AST node types
- SymbolFlags - Symbol classification flags
- Type Checker API - Working with types