Skip to content

TypeScript practice

Practice TypeScript online: 10 exercises, graded problems and a playground

Every run here goes through the real TypeScript compiler, loaded into your browser, before the resulting JavaScript executes — so a type error stops the program with the same message tsc would give, and the exercises can teach types honestly instead of pretending they are comments. Three of the exercises begin with a program that deliberately fails to compile.

checked exercises
10
graded problems
0
lessons
9
cheat sheet
1

TypeScript practice exercises

How the path works →

In order, each one introducing a single new idea. Press Run to check your answer; hints open one at a time.

  1. Checked, Then Runconsole.log() puts text on the screen
  2. Luggage Tagconst gives a value a name you can use again
  3. Egg Boxesnumbers do arithmetic, and Math.floor and % split a count into whole groups and a remainder
  4. The Ticket Machinea type annotation such as : number says what a name must hold, and a value that does not match stops the program before it runs
  5. The Fern Checka boolean is true or false, and if/else runs one of two blocks depending on it
  6. Parcel Postagea function takes typed parameters and returns a typed result
  7. The League Tabletemplate literals build text with values inside it
  8. The Number 12 Busan array type such as string[] holds several values of one type, and for...of walks through them
  9. The Departure Boardan object type lists the properties an object must have, and the compiler checks every object against it
  10. The Bike Shop Receiptassembling a complete program out of parts you already know

TypeScript lessons behind the practice

All lessons →

TypeScript cheat sheet

Everyday syntax on one page, for when you remember the idea but not the spelling.

Coding interview questions

Original questions with full model answers, for when the practice is going somewhere specific.

Questions people ask

Does the type checking actually run, or is this just JavaScript with annotations?
It runs. The TypeScript compiler itself executes in your browser tab on every Run, and a program with a type error is refused with the real compiler diagnostic before any of it executes.
Which TypeScript version is used?
The version shown on the playground page, loaded from a copy of the official compiler package kept on this site rather than from a CDN. It is updated deliberately, not silently.
Should I learn JavaScript first?
It helps but is not required: the TypeScript exercises introduce the same basics — printing, variables, loops, functions — and add a type each time one makes the code clearer. If you already know JavaScript, the first few exercises will be quick.
What is on this page besides the exercises?
The 10 exercises are the start. After them: 9 in-depth lessons, a cheat sheet for the syntax and a blank playground.

Practise another language

The same kind of practice hub exists for Python, JavaScript, Java, C++, C, C#, Go, PHP, Ruby, SQL, R and Bash & the Shell.