Free course

TypeScript Course

Learn TypeScript from the JavaScript you already know: inference, annotations, objects, unions, functions, generics, narrowing, and compiler configuration.

6 modules · 42 lessons · No signup

Prerequisites: JavaScript

~~~

Your progress

of lessons completed.

Course completed.

What you'll learn

Add useful types to a small JavaScript program, configure the compiler, and handle uncertain data without turning type checking off.

Take this course offline

Subscribe to my newsletter to get every free book, downloadable course, and complete software download.

Get the downloads

Course contents

  1. Start using TypeScript

    Install the compiler, run a first program, and read type errors.

    1. What TypeScript adds to JavaScript
    2. Install TypeScript in a project
    3. Write and compile your first program
    4. Read a TypeScript error
    5. Types do not change runtime behavior
  2. Types and inference

    Primitives, arrays, tuples, annotations, and special types.

    1. Let TypeScript infer obvious types
    2. Add a type annotation when it helps
    3. Use the primitive types
    4. Type arrays
    5. Use a tuple for fixed positions
    6. TypeScript: any vs unknown vs never
    7. Handle null and undefined deliberately
    8. Check your understanding: types and inference
  3. Objects and unions

    Describe object shapes and compose types deliberately.

    1. Describe an object shape
    2. TypeScript interfaces vs types: which one to use
    3. Optional and readonly properties
    4. TypeScript type for a string or array of strings
    5. Restrict values with literal unions
    6. Combine requirements with intersections
    7. Check your understanding: objects and unions
  4. Functions and generics

    Type calls, callbacks, reusable functions, and constraints.

    1. Type function parameters
    2. Use inferred and explicit return types
    3. Type callbacks
    4. Object destructuring with types in TypeScript
    5. TypeScript generics explained simply
    6. Constrain a generic only when necessary
    7. Check your understanding: functions and generics
  5. Narrowing uncertain values

    Refine unions with checks, guards, and discriminants.

    1. Narrow with typeof
    2. Narrow with equality, null checks, and truthiness
    3. Narrow with in and instanceof
    4. Model states with a discriminated union
    5. Type predicates and assertions
    6. Type narrowing and type guards in TypeScript
    7. Check your understanding: narrowing
  6. The compiler and runtime

    Configure strict checking and understand where types stop.

    1. Create a tsconfig.json
    2. Enable strict checking
    3. Type-check without emitting files
    4. Understand type erasure
    5. Use declaration files
    6. Validate data at runtime
    7. Build a typed task list
    8. Check your understanding: compiler and runtime