JavaScript · Advanced level

Advanced level · Module 4 of 6 · 22 guided hours

TypeScript Essentials

Add static types to JavaScript with TypeScript to catch mistakes early and make larger codebases easier to change.

Learning objectives

  • Set up TypeScript and the type checker
  • Type data with interfaces, unions and generics
  • Narrow types safely and migrate JavaScript gradually

Topics

  • tsc and tsconfig
  • basic and literal types
  • interfaces and type aliases
  • unions and narrowing
  • generics
  • typing DOM and fetch results
  • gradual migration

Lessons

  1. Lesson 1 Why Types: Setting Up TypeScript

    Understand what static types add to JavaScript and set up the TypeScript compiler in strict mode.

    static typingtsctsconfig.json and stricttype checking vs running

  2. Lesson 2 Types for Data: Interfaces, Unions and Literals

    Describe data shapes with interfaces and type aliases, and model choices with union and literal types.

    interface and type aliasoptional propertiesunion typesliteral types

  3. Lesson 3 Narrowing and Generics

    Narrow union types safely in code and write reusable functions and types with generics.

    type narrowingdiscriminated uniongeneric function <T>unknown vs any

  4. Lesson 4 Migrating JavaScript to TypeScript

    Convert an existing JavaScript codebase gradually, typing the DOM and third-party code along the way.

    gradual migrationallowJs and checkJsDOM typestype declarations

Practical activity

Migrate the visit tracker's logic and API modules to TypeScript in strict mode and fix every error the checker reports.

Expected outcomes

  • Type-safe JavaScript code
  • Bugs caught before running the program

Assessment

Practical: type a provided module in strict mode with no any; marked by tsc output and review.

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.