Learn TypeScript by writing console programs that run on Deno, from typed variables and functions to interfaces, generics and a small final project.
15 lessons, 30 exercises. Runs TypeScript Deno.
Not started
Hello, output
Print text with console.log, write comments, and see how Deno runs a TypeScript file.
Values and types
Declare variables with const and let, annotate them with types, and let TypeScript infer types for you.
Reading input and arithmetic
Read all of standard input in Deno, convert text to numbers, and calculate with TypeScript's operators.
Making decisions
Branch with if, else and switch, compare values safely, and see how TypeScript narrows union types inside each branch.
Loops
Repeat work with for, while and for...of loops, and control them with break and continue.
Functions
Write functions with typed parameters and return values, use optional and default parameters, and describe function types.
Collections
Store many values in typed arrays and tuples, and look values up by key with Record and Map.
Strings and a small project
Search, slice, transform and pad strings, then combine everything so far into a text statistics tool.
Handling errors
Throw and catch exceptions, narrow the unknown value in a catch block, write custom error classes, and return errors as typed result values.
Structuring data
Describe data with interfaces and type aliases, mark properties optional or readonly, and build classes with private state that implement interfaces.
Recursion
Write functions that call themselves on smaller inputs, and describe nested data with recursive types.
Sorting and searching
Sort arrays with typed compare functions, order by several keys, and search sorted data with binary search.
Maps and sets in depth
Count and group with typed Maps, remove duplicates and compare collections with Set operations.
Types and generics
Write generic functions with constraints, model data with discriminated unions and exhaustive checks, and reshape types with keyof and utility types.
Final project
Design and build two larger typed programs, a gradebook report and a task tracker, combining interfaces, unions, classes, maps and error handling.
Your progress is saved in this browser. Sign in to keep it on every device.