Skip to content
aviral gupta

// LEARN · LANGUAGES & FRAMEWORKS

TypeScript

A practical TypeScript course from a first compiler error to generics, type-level programming, declaration files and large projects. Every example is compiled and checked against TypeScript 7.0.

Level: Beginner to advanced · For: Developers who know some JavaScript and want the compiler to catch their mistakes, from a first type to a typed codebase.

Syllabus

Beginner

Complete

After this level you can

  • Install TypeScript 7.0, run tsc on a project with a tsconfig.json, and read a compiler error to fix the code
  • Annotate variables, functions and object shapes, and explain when inference makes an annotation unnecessary
  • Model alternatives with union and literal types and narrow them safely, including exhaustiveness checks with never
  • Type functions with optional, default and rest parameters, overloads and function type expressions
  • Describe object data with optional and readonly properties, index signatures, intersections and tuples
  1. B1Setup and the basics5 of 5 written · 5 lessonsRuns on your computer
  2. B2Everyday types5 of 5 written · 5 lessonsRuns in your browser
  3. B3Narrowing5 of 5 written · 5 lessonsRuns in your browser

    Handle each member of a union safely, with discriminated unions and exhaustiveness checks

    You build: An order-status state machine

    1. B3.1Union types and narrowing
    2. B3.2typeof, truthiness, equality and in
    3. B3.3instanceof and type predicates
    4. B3.4Discriminated unions
    5. B3.5never and exhaustiveness; build: an order-status state machine
  4. B4More on functions5 of 5 written · 5 lessonsRuns in your browser
  5. B5Object types5 of 5 written · 5 lessonsRuns in your browser

    Describe real data shapes with readonly properties, index signatures, intersections and tuples

    You build: A typed inventory loader

    1. B5.1Optional and readonly properties
    2. B5.2Index signatures
    3. B5.3Extending types and intersections
    4. B5.4Array<T>, ReadonlyArray and tuples
    5. B5.5Object types together; build: a typed inventory loader

Beginner project

Typed expense splitter

A strict TypeScript program that splits expenses between people, models payment states as a discriminated union and fails to compile when a state is not handled.

Runs in your browserSelf-checked against a rubric

Open the project guide

Intermediate

Coming soon

After this level you can

  • Write generic functions, interfaces and classes with constraints and defaults
  • Derive types from other types with keyof, typeof, indexed access, conditional, mapped and template literal types
  • Type classes with visibility modifiers, implements, abstract members and generic this
  • Configure a multi-file project with module, moduleResolution and verbatimModuleSyntax, and explain ESM and CommonJS interop
  • Apply the built-in utility types and explain structural type compatibility
  1. I1GenericsComing soon · 5 lessonsRuns in your browser

    Write reusable, type-safe code with generic functions, interfaces and classes

    You build: A typed cache

    1. I1.1Coming soon
    2. I1.2Coming soon
    3. I1.3Coming soon
    4. I1.4Coming soon
    5. I1.5Coming soon
  2. I2Types from typesComing soon · 6 lessonsRuns in your browser

    Derive types instead of repeating them, with keyof, conditional, mapped and template literal types

    You build: A typed event emitter

    1. I2.1Coming soon
    2. I2.2Coming soon
    3. I2.3Coming soon
    4. I2.4Coming soon
    5. I2.5Coming soon
    6. I2.6Coming soon
  3. I3ClassesComing soon · 5 lessonsRuns in your browser

    Type object-oriented code with modifiers, implements and abstract classes

    You build: A typed shape hierarchy

    1. I3.1Coming soon
    2. I3.2Coming soon
    3. I3.3Coming soon
    4. I3.4Coming soon
    5. I3.5Coming soon
  4. I4Modules and project configurationComing soon · 5 lessonsRuns on your computer

    Configure a real multi-file project, choosing between nodenext and bundler

    You build: A multi-file command-line tool compiled with tsc

    1. I4.1Coming soon
    2. I4.2Coming soon
    3. I4.3Coming soon
    4. I4.4Coming soon
    5. I4.5Coming soon
  5. I5Utility types and compatibilityComing soon · 5 lessonsRuns in your browser

    Use the built-in utility types and explain structural typing

    You build: A typed API client

    1. I5.1Coming soon
    2. I5.2Coming soon
    3. I5.3Coming soon
    4. I5.4Coming soon
    5. I5.5Coming soon

Intermediate project

Typed CLI task manager

A multi-file ES module project with generic repository classes, a JSON file store, a typed command parser, typed errors and no any.

Runs on your computerSelf-checked against a rubric

Advanced

Coming soon

After this level you can

  • Write and publish declaration files, and augment third-party types
  • Add types to an existing JavaScript codebase with checkJs and JSDoc, then migrate it file by file
  • Use distributive and recursive conditional types, satisfies, const type parameters and variance annotations
  • Structure a large codebase with project references and tsc -b, and migrate a 6.x configuration to 7.0
  • Validate untrusted input at runtime boundaries, and run TypeScript in Node.js with type stripping
  1. A1Declaration filesComing soon · 5 lessonsRuns on your computer

    Type code you did not write, with .d.ts files and module augmentation

    You build: Types for an untyped library

    1. A1.1Coming soon
    2. A1.2Coming soon
    3. A1.3Coming soon
    4. A1.4Coming soon
    5. A1.5Coming soon
  2. A2Typing and migrating JavaScriptComing soon · 5 lessonsRuns on your computer

    Add types to an existing JavaScript codebase and tighten strictness step by step

    You build: Migrating a small JavaScript project

    1. A2.1Coming soon
    2. A2.2Coming soon
    3. A2.3Coming soon
    4. A2.4Coming soon
    5. A2.5Coming soon
  3. A3Advanced type-level programmingComing soon · 5 lessonsRuns in your browser

    Express precise APIs in the type system

    You build: Typed URL-route parameters

    1. A3.1Coming soon
    2. A3.2Coming soon
    3. A3.3Coming soon
    4. A3.4Coming soon
    5. A3.5Coming soon
  4. A4Decorators, symbols and iterationComing soon · 5 lessonsRuns in your browser

    Type decorators, symbols, iterators, generators and mixins

    You build: Logging and timing decorators

    1. A4.1Coming soon
    2. A4.2Coming soon
    3. A4.3Coming soon
    4. A4.4Coming soon
    5. A4.5Coming soon
  5. A5Projects at scale and 7.0Coming soon · 5 lessonsRuns on your computer

    Build and maintain large codebases with project references, and migrate to 7.0

    You build: A three-package workspace

    1. A5.1Coming soon
    2. A5.2Coming soon
    3. A5.3Coming soon
    4. A5.4Coming soon
    5. A5.5Coming soon
  6. A6Runtime boundaries and publishingComing soon · 5 lessonsRuns on your computer

    Keep types honest at the edges and publish a typed package

    You build: A validated config loader

    1. A6.1Coming soon
    2. A6.2Coming soon
    3. A6.3Coming soon
    4. A6.4Coming soon
    5. A6.5Coming soon

Advanced project

Typed HTTP client library

A small package with a typed route map, runtime validation of responses, generated declaration files and project references.

Runs on your computerSelf-checked against a rubric

Capstone

Capstone

Migrate a JavaScript app to strict TypeScript

Migrate a provided JavaScript app in stages, from JSDoc and checkJs to strict TypeScript 7.0, keeping its tests green and writing a migration log.

Runs on your computerSelf-checked against a rubric

Sources