Skip to content
iamnoobs

Beginner to advanced · 13 modules · 39 lessons

Learn TypeScript: Beginner to Advanced

Learn TypeScript from the foundations of static typing to generics, narrowing, asynchronous code, tooling, and application design through short lessons, examples, quizzes, and a capstone.

Who this is for: Learners who know basic programming or JavaScript and want to build maintainable applications with TypeScript's static type system.

Prerequisites: No prior TypeScript experience is required. Familiarity with basic programming concepts is helpful; JavaScript knowledge makes the examples easier to follow. Examples are explanatory and are not compiled or executed on this website.

Meet TypeScript and the compiler

What TypeScript is

TypeScript adds a static type system and tooling on top of JavaScript.

TypeScript is a language built on JavaScript. It understands JavaScript syntax and adds types that can describe the values a program expects. TypeScript code is normally checked and then transformed into JavaScript for a runtime such as a browser or Node.js.

Types help editors and the compiler detect many mistakes before a program runs. They do not automatically validate data received from a network, file, or user: runtime input still needs checks.

Guided example

Read through this example; code examples are for learning and are not executed on this site.

function greet(name: string): string {
  return `Hello, ${name}`;
}

const message = greet("Ada");

Relevance quest · +10 XP

What does TypeScript normally produce for execution?

Choose your answer

Mark this lesson complete when you are ready.

Module checkpoint: Meet TypeScript and the compiler

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.

After this module, you can:

  • Explain the relationship between TypeScript and JavaScript.
  • Recognize the roles of the TypeScript compiler and tsconfig.json.
  • Use type annotations and type inference in simple programs.

Full curriculum

What you will learn

1. Meet TypeScript and the compiler

Beginner

Understand what TypeScript adds to JavaScript, how type checking works, and how source files become executable JavaScript.

  1. What TypeScript is

    TypeScript adds a static type system and tooling on top of JavaScript.

  2. The compiler and tsconfig.json

    The TypeScript compiler checks source files according to project settings.

  3. 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

Beginner

Describe common values with TypeScript's built-in types and combine possible values safely.

  1. Primitive and special types

    Primitive annotations describe common JavaScript values precisely.

  2. Literal and union types

    Union types allow a value to be one of several declared alternatives.

  3. 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

Beginner

Create typed functions with clear parameters, return values, optional arguments, and callback contracts.

  1. Function parameters and return types

    Function types define what callers must provide and what a function returns.

  2. Optional, default, and rest parameters

    Parameter syntax communicates which arguments callers may omit.

  3. 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

Beginner

Model structured data with object types, reusable aliases, readonly properties, arrays, and tuples.

  1. Object types and optional properties

    Object types state which properties an object may or must contain.

  2. Arrays and tuples

    Arrays hold a sequence of values while tuples describe fixed-position types.

  3. 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

Intermediate

Use runtime checks and control-flow analysis to safely work with values that may have different types.

  1. Control-flow type narrowing

    TypeScript tracks checks through branches to refine a value's possible type.

  2. The in operator and custom type guards

    Type guards describe checks that establish which shape a value has.

  3. 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

Intermediate

Write reusable functions and structures that preserve relationships between input and output types.

  1. Generic functions

    A type parameter lets one function work with multiple types without losing information.

  2. Generic constraints and keyof

    Constraints limit a type parameter to values that support required operations.

  3. 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

Intermediate

Build class-based models with constructors, access control, inheritance, and interface contracts.

  1. Classes, fields, and constructors

    Classes describe objects with data and behavior and are available at runtime.

  2. Access modifiers and readonly members

    Member modifiers control how class state may be accessed and changed.

  3. 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

Advanced

Transform and compose types with intersections, mapped types, conditional types, and built-in utilities.

  1. Intersection and indexed access types

    Intersection and indexed access types build new types from existing definitions.

  2. Mapped and conditional types

    Mapped types iterate over keys and conditional types select a type based on a relationship.

  3. 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

Intermediate

Organize TypeScript code into modules and understand package configuration and declaration files.

  1. Exporting and importing modules

    Modules divide a program into files with explicit dependencies and public exports.

  2. Package configuration and module resolution

    Project and package settings help tools resolve code and choose output formats.

  3. 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

Intermediate

Represent asynchronous results with Promise types and write clear async workflows with safe error handling.

  1. Promises and Promise<T>

    A promise represents a result that may become available in the future.

  2. async and await

    async and await let asynchronous code be written in a sequential style.

  3. 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

Intermediate

Work with external data safely and connect TypeScript code to JSON and browser interfaces.

  1. Static types versus runtime validation

    Types protect code during development but do not inspect external data automatically.

  2. JSON parsing and serialization

    JSON APIs exchange runtime data that should be checked before being trusted.

  3. 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

Advanced

Use compiler checks, linting, tests, and build tooling to maintain a reliable TypeScript project.

  1. Type checking, builds, and linting

    Type checking, transpilation, bundling, and linting solve related but different problems.

  2. Unit testing typed code

    Tests verify runtime behavior while types help describe valid inputs and outputs.

  3. 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

Advanced

Bring TypeScript concepts together with layered boundaries, API contracts, error handling, and maintainable project design.

  1. Organize an application into layers

    Clear boundaries keep domain rules independent from user interfaces and infrastructure.

  2. Typed API contracts and error boundaries

    API types document expectations while runtime code checks responses and failures.

  3. 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.

Put it together

TypeScript capstone: Personal Study Planner

Build a small study planner that lets a learner create, update, complete, filter, and remove study tasks. Model the domain with TypeScript types, keep application logic separate from the user interface, persist data through a repository implementation, and validate any data loaded from storage or an API before using it.

  1. 1Define Task, TaskStatus, and planner state types using interfaces, aliases, and discriminated unions where appropriate.
  2. 2Implement typed functions for creating, updating, completing, filtering, and removing tasks.
  3. 3Create a repository interface and a local implementation for saving and loading planner data.
  4. 4Validate parsed JSON as unknown before converting it into trusted task values; handle invalid or missing data safely.
  5. 5Build an interface with typed events and form handling, then add tests for normal, empty, invalid, and boundary cases.
  6. 6Enable strict compiler checks, run type checking and tests, and document how to build and run the application.

Progress is saved in this browser when local storage is available. You can continue without an account; changing browsers or clearing browser data may remove saved progress. Examples are not executed by the site.