# TypeScript Playground

Transpile TypeScript and run it in your browser with live console output, interactive input and coding examples.

## URL

https://ilham.dev/tools/typescript-playground/

## What It Does

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.

## Features

- Browser-side transpilation
- Syntax diagnostics
- Interactive async prompt
- Run and Stop
- Coding exercises and pyramid patterns

## Input

Single TypeScript snippet typescript input.

## Output

Logs, returned values and errors console output.

## Privacy

Processing happens locally in the browser.

No input data is uploaded to ilham.dev.

- Requires login: false
- Requires API key: false
- Stores user data: false


## Examples

- Does this check TypeScript types?
- Can I use await and interactive input?
- Does clicking an example run it?
- Can I import npm packages?
- What happens when code never finishes?


## Limitations

- Transpilation does not perform semantic type-checking.
- The compiler loads from jsDelivr on Run. No Node.js or package imports.
- Worker execution is not a security sandbox; snippets can make network requests.
- Execution is limited to 30 seconds and 500 output rows.


## Related Tools

- https://ilham.dev/tools/javascript-playground/
- https://ilham.dev/tools/python-playground/
- https://ilham.dev/tools/ruby-playground/
- https://ilham.dev/tools/c-playground/
- https://ilham.dev/tools/cpp-playground/


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

