Practice TypeScript online
A free TypeScript editor that runs in your browser. Press Run and the real TypeScript compiler checks your program first, with errors that point to the line, then runs it. prompt() works for typed answers, and console.log prints like Node.js. There's nothing to install and no account to make.
TypeScript 5.9, strict · free · no sign-up · runs in your browser
TypeScript practice problems for beginners
Each one opens in the editor above as a working program with something left for you to finish.
- problem 1
Greet me
Ask for a name and an age with prompt(), then print one sentence that uses both. TypeScript knows prompt() can give back null, so handle that.
- problem 2
Fix the types
This program has three type errors. Press Run to see what TypeScript says, then fix each one without deleting any lines.
- problem 3
Describe a game
Write an interface for a video game (a title, a year and whether it's multiplayer), make a list of three, and print the ones from after 2015.
- problem 4
Traffic light
Use a union type so a light can only be red, yellow or green, and write a function that returns what each one means.
- problem 5
Last item
Write a generic function last<T> that returns the last item of any array, or undefined when it's empty, and test it on numbers and words.
A free online TypeScript compiler that runs in your browser
- The real TypeScript 5.9 compiler, in strict mode, the way most projects set it up
- Type errors show the line and the message, the way tsc prints them, before anything runs
- Then it runs: console.log prints arrays and objects like Node.js, and prompt() reads a typed answer
- Interfaces, union types, generics, enums and classes all work
- Your code is remembered in your browser, and Share gives you a link
- Runtime errors point to the line in your TypeScript, not the JavaScript it turned into
TypeScript editor questions
Is this TypeScript editor free?
Yes. It's free, with no sign-up, no ads and no tracking. Your code runs in your own browser and isn't sent anywhere unless you press Share to make a link.
Which version of TypeScript is it?
TypeScript 5.9, with strict mode on and the standard library up to ES2022. Your program is one file and runs as a script, so import and export aren't available.
Does it really check types, or just remove them?
It really checks them. The program only runs when the compiler finds no errors, so a mistake like putting text where a number goes is caught before anything runs. That's the point of TypeScript.
Does prompt() work?
Yes. When your program calls prompt(), it pauses and you type your answer in the console. TypeScript knows prompt() can give back null (when there's nothing to read), so write prompt("Name?") ?? "" to get a string either way.
Does it work on a Chromebook, iPad or phone?
Yes, in any up-to-date browser: Chrome, Safari, Edge or Firefox, including school Chromebooks. The first run downloads about 4 MB, then your browser keeps it, so later visits start fast.
Is my code saved?
Your code is remembered in your browser, so it's there when you come back on the same device. To keep a copy or send it to someone, press Share for a link, or Copy.
Are there any limits?
A program can run for 10 seconds (time spent waiting for you to type doesn't count), and programs can be up to 20,000 characters. That's plenty for practice problems, school assignments and small projects.
Want a coach while you practice?
HopeCoders teaches TypeScript 1-on-1 for all ages, from first programs to school projects. Every coach is background checked, and sessions happen in person across Greater Los Angeles, from Pasadena, Burbank and Beverly Hills to the South Bay, Long Beach and north Orange County, or online over Zoom.