TypeScript code

Press Ctrl/Cmd + Enter to run. Auto-run reruns 700 ms after editing. Enable Monaco for highlighting and formatting; it loads from a CDN only when requested.

The TypeScript 5.9.3 compiler downloads from jsDelivr on your first Run. This runner transpiles code and reports syntax errors; it does not perform semantic type-checking. No Node.js or package imports.

Code examples (22)

Click an example to add it above your code. Existing code stays; Auto-run is paused. Clear the editor first if you want to run only the example.

Basics

Number exercises

Logic exercises

Arrays and search

Functions and OOP

Star patterns

TypeScript types

Plain editor
0 lines · 0 chars

Output

Output streams live, including timers. Use await prompt('Your name?') for interactive input. Runs in a Web Worker, without direct DOM access. Stop terminates execution; each run has a 30-second execution limit and output is capped at 500 rows. Code can still make network requests, so only run code you trust. The tool does not save or upload your code or input.

Learn

TypeScript Playground Guide

About this tool

Transpile TypeScript 5.9.3 to JavaScript and run it in a disposable browser Worker. The console shows logs, return values and errors. The compiler loads from jsDelivr only on Run or when Auto-run is enabled; Monaco loads separately on demand. Examples cover arithmetic, prime numbers, sorting, classes and pyramid patterns, plus TypeScript interfaces and generics. Transpilation reports syntax errors but does not perform semantic type-checking. The tool does not save or upload code or prompt answers; snippets can still make network requests.

Questions

Does this check TypeScript types?
No. The runner uses transpileModule, which removes types and reports syntactic errors. A mismatched type can still run. Monaco may display additional editor diagnostics when enabled, but the runner does not enforce them.
Can I use await and interactive input?
Yes. The transpiled snippet runs inside an async function. Use await prompt(‘Question’) and enter an answer in the output panel. Ask one question at a time; return displays a result.
Does clicking an example run it?
No. An example is inserted in a separate block above existing code, and Auto-run is paused. Clear the editor first to run only that example, then press Run.
Can I import npm packages?
No. This is a single-snippet browser runner, not Node.js or a project bundler. document and window are also unavailable inside the Worker.
What happens when code never finishes?
Stop terminates the Worker. Runtime loading has a 90-second timeout, and execution has a separate 30-second limit. Output is capped at 500 rows; input remains available to edit.