Primitives
TypeScript builds on JavaScript by adding types, so we can describe exactly what kind of values a variable
Explore our comprehensive collection of typescript exercises. From basics to advanced patterns.
TypeScript builds on JavaScript by adding types, so we can describe exactly what kind of values a variable
Functions are how we structure behavior. In TypeScript, you can describe parameter types and return types so
Objects model real-world entities. In TypeScript, you describe an object's shape by listing its properties
Arrays are ordered lists of values written as T[] or Array<T>: `typescript const numbers: number[] = [1, 2,
Union types let a value be one of several possibilities, while literal types restrict values to exact
Type aliases give a name to any type so you can reuse it throughout your code: `typescript type UserId =
Interfaces describe the shape of an object: `typescript interface User { id: number; name: string; email?:
When strict null checks are on, null and undefined must be handled explicitly. This helps you avoid crashes
Type assertions tell TypeScript how to treat a value. They do not change runtime behavior—they only affect
any turns off type checking completely. It spreads quickly through your code and hides bugs. Prefer unknown
Type guards help the compiler figure out which shape a value has at a given point. When a check succeeds,
Generics let you write components that work over many types without losing type safety: `typescript function
Functions are the heart of TypeScript programs. You can describe a function's shape with a call signature:
Utility types help you reshape and remix existing types without rewriting them: `typescript type User = { id:
This deep dive builds on basic object types with advanced patterns: Intersections – Combine multiple types
This category links runtime values to static types using powerful type operators: keyof – Get all property