TypeScript
TypeScript cheat sheet covering types, interfaces, generics, utility types, type guards, and advanced type system features with examples.
Basic Types
Primitive Types
TypeScript basic primitive types and type annotations
Type Aliases, Unions & Intersections
Create custom types with aliases, combine with unions and intersections
Enums
Named constants with numeric or string values
Tuples & Readonly
Fixed-length typed arrays and immutable modifiers
Functions
Function Types
Type annotations for functions and their parameters
Function Overloading
Define multiple function signatures for different parameter types
Interfaces & Classes
Interfaces
Define object shapes and contracts for type checking
Classes
Object-oriented programming with TypeScript classes
Inheritance
Class inheritance and method overriding in TypeScript
Generics
Generic Functions
Create reusable functions that work with multiple types
Generic Classes & Interfaces
Build flexible classes and interfaces with generic types
Type Operations
Operators and assertions for querying and transforming types
Type Assertions (as, satisfies, as const)
Tell the compiler about types it cannot infer automatically
keyof, typeof & Indexed Access
Query types from existing values and access type properties by key
Advanced Types
Utility Types
Built-in generic types for common type transformations
Type Guards & Narrowing
All the ways to narrow types in conditional blocks
Mapped, Conditional & Template Literal Types
Transform and construct types programmatically
Decorators
Stage 3 decorators for classes, methods, and properties (TypeScript 5+)
Decorators (TypeScript 5+)
Annotate and modify classes and their members with decorator functions
Modules & Namespaces
Imports & Exports
ES6 module syntax for importing and exporting code
Declaration Files
Type declarations for JavaScript libraries and modules
TSConfig Reference
Compiler Options Reference
Complete reference of TypeScript compiler options with descriptions and values