1. Meet TypeScript and the compiler
BeginnerUnderstand what TypeScript adds to JavaScript, how type checking works, and how source files become executable JavaScript.
What TypeScript is
TypeScript adds a static type system and tooling on top of JavaScript.
The compiler and tsconfig.json
The TypeScript compiler checks source files according to project settings.
Type annotations and inference
Types can be written explicitly or inferred from initial values and context.
Module checkpoint: Try it: write a function that accepts a string and returns a greeting. Add a return type, then remove it and observe what the compiler infers.
2. Primitive types, literals, and unions
BeginnerDescribe common values with TypeScript's built-in types and combine possible values safely.
Primitive and special types
Primitive annotations describe common JavaScript values precisely.
Literal and union types
Union types allow a value to be one of several declared alternatives.
any, unknown, and never
These types express different levels of certainty and impossible values.
Module checkpoint: Try it: define a Status union with three string literals, then write a function that accepts only that Status type.
3. Functions and callable types
BeginnerCreate typed functions with clear parameters, return values, optional arguments, and callback contracts.
Function parameters and return types
Function types define what callers must provide and what a function returns.
Optional, default, and rest parameters
Parameter syntax communicates which arguments callers may omit.
Function types and callbacks
Callback types describe functions that are passed as values.
Module checkpoint: Try it: write a typed function that accepts an array of numbers and a callback, then call the callback once for each number.
4. Objects, arrays, and tuples
BeginnerModel structured data with object types, reusable aliases, readonly properties, arrays, and tuples.
Object types and optional properties
Object types state which properties an object may or must contain.
Arrays and tuples
Arrays hold a sequence of values while tuples describe fixed-position types.
Type aliases, interfaces, and readonly
Named types make data contracts easier to share and maintain.
Module checkpoint: Try it: define an interface for a Course with an id, title, and optional description. Create a readonly array of courses.
5. Union types and narrowing
IntermediateUse runtime checks and control-flow analysis to safely work with values that may have different types.
Control-flow type narrowing
TypeScript tracks checks through branches to refine a value's possible type.
The in operator and custom type guards
Type guards describe checks that establish which shape a value has.
Discriminated unions and exhaustive checks
A shared literal property makes variants easy to distinguish and verify.
Module checkpoint: Try it: define a loading, success, and error state as a discriminated union, then write a function that handles all three cases.
6. Generics and reusable abstractions
IntermediateWrite reusable functions and structures that preserve relationships between input and output types.
Generic functions
A type parameter lets one function work with multiple types without losing information.
Generic constraints and keyof
Constraints limit a type parameter to values that support required operations.
Generic interfaces and classes
Generic types can describe reusable containers and service contracts.
Module checkpoint: Try it: write a generic function that returns the first item from an array, and then add a constraint to read an id property from objects.
7. Classes and object-oriented TypeScript
IntermediateBuild class-based models with constructors, access control, inheritance, and interface contracts.
Classes, fields, and constructors
Classes describe objects with data and behavior and are available at runtime.
Access modifiers and readonly members
Member modifiers control how class state may be accessed and changed.
Inheritance and interfaces
Inheritance reuses class behavior while interfaces describe compatible contracts.
Module checkpoint: Try it: define a base class for a notification and a subclass for an email notification. Give both a common typed method.
8. Advanced and utility types
AdvancedTransform and compose types with intersections, mapped types, conditional types, and built-in utilities.
Intersection and indexed access types
Intersection and indexed access types build new types from existing definitions.
Mapped and conditional types
Mapped types iterate over keys and conditional types select a type based on a relationship.
Built-in utility types
Utility types derive common variants of existing types without repeating their structure.
Module checkpoint: Try it: define a User type, derive a UserPreview with Pick, and derive a UserPatch with Partial. Explain which fields each type permits.
9. Modules, packages, and declarations
IntermediateOrganize TypeScript code into modules and understand package configuration and declaration files.
Exporting and importing modules
Modules divide a program into files with explicit dependencies and public exports.
Package configuration and module resolution
Project and package settings help tools resolve code and choose output formats.
Declaration files and ambient types
Declaration files describe types for JavaScript code and external APIs.
Module checkpoint: Try it: split a small program into two modules, export a function from one, import it in the other, and add a package script for type checking.
10. Promises and asynchronous TypeScript
IntermediateRepresent asynchronous results with Promise types and write clear async workflows with safe error handling.
Promises and Promise<T>
A promise represents a result that may become available in the future.
async and await
async and await let asynchronous code be written in a sequential style.
Async errors and concurrent tasks
Use try/catch and Promise combinators to coordinate asynchronous work.
Module checkpoint: Try it: write an async function that loads two independent values concurrently with Promise.all and handles a rejected promise.
11. Runtime data, JSON, and browser APIs
IntermediateWork with external data safely and connect TypeScript code to JSON and browser interfaces.
Static types versus runtime validation
Types protect code during development but do not inspect external data automatically.
JSON parsing and serialization
JSON APIs exchange runtime data that should be checked before being trusted.
DOM elements and event handling
DOM library types describe browser elements, events, and user interactions.
Module checkpoint: Try it: parse a JSON string as unknown, validate its required fields, and write a browser event handler that checks whether its target element exists.
12. Tooling, testing, and code quality
AdvancedUse compiler checks, linting, tests, and build tooling to maintain a reliable TypeScript project.
Type checking, builds, and linting
Type checking, transpilation, bundling, and linting solve related but different problems.
Unit testing typed code
Tests verify runtime behavior while types help describe valid inputs and outputs.
Strict mode and maintainable code
Strict checks and clear boundaries make assumptions explicit across a codebase.
Module checkpoint: Try it: add a typecheck script, enable strict mode, and write tests for a function's normal, empty, and boundary inputs.
13. Application design and production readiness
AdvancedBring TypeScript concepts together with layered boundaries, API contracts, error handling, and maintainable project design.
Organize an application into layers
Clear boundaries keep domain rules independent from user interfaces and infrastructure.
Typed API contracts and error boundaries
API types document expectations while runtime code checks responses and failures.
Production readiness and code review
A release review checks behavior, configuration, observability, and maintainability.
Module checkpoint: Review your capstone for clear module boundaries, validated external data, handled asynchronous failures, meaningful tests, and a reproducible production build.