TypeScript Mastery
Go from the first annotated variable to writing your own conditional, mapped and infer-based utility types, while keeping a clear line between compile-time checking and runtime behavior.
What you will be able to do
#- Explain what TypeScript erases at compile time and what still runs at runtime.
- Narrow union types safely with typeof, truthiness, equality, in and custom type guards.
- Model objects and functions with interfaces, type aliases, overloads and optional or readonly members.
- Write generic functions and constraints that infer their arguments instead of begging for annotations.
- Use and then reimplement built-in utility types such as Partial, Pick, Omit and Record.
- Build conditional, mapped, keyof and template literal types, including infer and key remapping.
- Prove type-level behavior with compile-time assertions instead of runtime logging.
- Model tuples, readonly arrays and const assertions to control literal widening.
- Choose between enums, const objects and union literal types for runtime-safe constants.
- Implement interfaces with classes and reason about structural compatibility.
- Author declaration files and module augmentation for untyped or extendable libraries.
- Separate type-only imports and keep modules compatible with isolatedModules.
- Reason about variance and write sound branded and recursive types.
- Type React components, hooks, async flows, builders and API clients with reusable patterns.
Prerequisites
#Lessons
#Compile-time types, runtime values
beginner · 35 minutes · 4 exercises
Describe how TypeScript annotations are erased before execution.
Inference, annotations and the unknown family
beginner · 40 minutes · 4 exercises
Predict when TypeScript infers a literal type and when it widens.
Union types and narrowing
beginner · 45 minutes · 4 exercises
Read a union type and describe the values it allows.
Objects, interfaces and structural typing
beginner · 40 minutes · 4 exercises
Choose between an interface and a type alias with a reason.
Type guards and discriminated unions
intermediate · 45 minutes · 4 exercises
Write a custom type guard with a `value is T` return type.
Functions, overloads and this
intermediate · 45 minutes · 4 exercises
Type function values, optional, default and rest parameters.
Generics and constraints
intermediate · 45 minutes · 4 exercises
Write a generic function that infers its type argument.
Built-in utility types
intermediate · 40 minutes · 4 exercises
Apply Partial, Required, Readonly, Pick, Omit and Record.
keyof, indexed access and satisfies
advanced · 45 minutes · 4 exercises
Use keyof and typeof to derive key unions.
Conditional types and infer
advanced · 50 minutes · 4 exercises
Write a conditional type with extends.
Mapped and template literal types
advanced · 50 minutes · 4 exercises
Write a mapped type over keyof T.
Capstone: build utility types from scratch
advanced · 60 minutes · 4 exercises
Reimplement Pick, Omit and DeepPartial using mapped and conditional types.
Tuples, readonly arrays and const assertions
intermediate · 45 minutes · 3 exercises
Read a tuple type and describe its fixed length and per-position types.
Enums and const object alternatives
intermediate · 40 minutes · 3 exercises
Declare numeric and string enums and read their emitted JavaScript.
Classes, implements and access modifiers
intermediate · 45 minutes · 3 exercises
Type class fields, constructors and methods, including parameter properties.
Declaration files and ambient types
intermediate · 45 minutes · 3 exercises
Write a .d.ts that describes a JavaScript module.
Module augmentation and declaration merging
advanced · 45 minutes · 3 exercises
Merge an interface across declarations.
Type-only imports and exports
intermediate · 40 minutes · 3 exercises
Use import type and export type to mark erased imports.
isolatedModules and safe single-file transpilation
intermediate · 40 minutes · 3 exercises
Explain what isolatedModules requires and why bundlers need it.
Assignability and variance
advanced · 50 minutes · 3 exercises
Explain covariance, contravariance and invariance in plain terms.
Migrating to strict mode
advanced · 45 minutes · 3 exercises
List what the strict family enables.
Branded and nominal types
advanced · 45 minutes · 3 exercises
Create a brand with a phantom property or intersection.
Recursive and deep types
advanced · 50 minutes · 3 exercises
Write a recursive conditional type with a base case.
Parsing strings with template literal types
advanced · 50 minutes · 3 exercises
Split a string type with infer and a template literal.
Type-checking performance
advanced · 45 minutes · 3 exercises
Identify type constructs that slow the checker.
Assertion functions and asserts
advanced · 45 minutes · 3 exercises
Write an assertion function with an asserts return type.
const type parameters and readonly inference
advanced · 45 minutes · 3 exercises
Use a const type parameter to infer literal types.
The Result pattern and typed errors
advanced · 45 minutes · 3 exercises
Model success and failure as a discriminated union.
Typing async code and promises
advanced · 45 minutes · 3 exercises
Type async functions and awaited values.
Factory functions and generic construction
advanced · 45 minutes · 3 exercises
Write a factory that infers its product type.
Typing the builder pattern
advanced · 45 minutes · 3 exercises
Build an object step by step with a chainable API.
Typing React props and children
intermediate · 45 minutes · 3 exercises
Type a component props object, including children.
Typing hooks and generic hooks
intermediate · 45 minutes · 3 exercises
Type useState, useRef and useReducer.
A typed API client
advanced · 50 minutes · 3 exercises
Type request and response shapes.
Type-level challenge set
advanced · 55 minutes · 3 exercises
Solve small type puzzles with conditional, mapped and template types.
Typed error handling
advanced · 45 minutes · 3 exercises
Narrow an unknown catch value safely.
Module resolution and package types
intermediate · 45 minutes · 3 exercises
Explain node16, bundler and classic resolution.
Decorators and metadata
advanced · 45 minutes · 3 exercises
Distinguish legacy and standard decorators.
Migrating JavaScript to TypeScript
intermediate · 45 minutes · 3 exercises
Enable allowJs and checkJs and read the errors.
Iterables, generators and async iterators
advanced · 45 minutes · 3 exercises
Type Iterable, Iterator and Generator.