Online TypeScript Compiler

Write, compile, run, and debug TypeScript online in a full-featured browser IDE. Manage multiple files and packages, save your workspace, and collaborate in real time.

🚀 1,087 total executions (46 this month)
Embed
Output

Practice Python with coding challenges

Solve hands-on problems right in this editor: run the sample tests, submit, and get an AI code review.

All Python challenges
Easy

Rectangle Perimeter

Compute the perimeter of a rectangle from its sides.

You'll learn ArithmeticReturn values
BeginnerLearning-pathVariables
Easy

Days in a Month

Return how many days a month has, including leap years.

You'll learn Calendar rulesHelper functions
BeginnerConditionsFunctionsLearning-path
Easy

Dot Product of Two Vectors

Multiply two vectors element by element and add the results: the core operation of every neuron.

You'll learn VectorsDot product
Neural networksaimachine learning
Easy

Distance Between Points

Compute the straight-line distance between two points.

You'll learn Pythagorean theoremSquare roots
BeginnerFunctionsLearning-pathmath
Easy

Average of Three

Average three whole numbers.

You'll learn ArithmeticDivision
BeginnerLearning-pathVariables
Easy

To-Do List

Keep a list of tasks: add them, mark them done, remove them and report what is still pending.

You'll learn Typed collectionsRecords
BeginnerSimulationStrings
Easy

Prime Number Check

Decide whether a number is prime.

You'll learn DivisibilityLoop optimization
BeginnerLoopsNumbersStudent-beginner
Hard

Word Break

Decide whether text can be split into dictionary words.

You'll learn Prefix DPString segmentation
AdvancedDynamic-programmingHackathonStrings
Easy

Count Pairs With a Sum

Count pairs of positions whose values add up to a target.

You'll learn Pairs of indexesAvoiding double counts
ArraysBeginnerLearning-pathNested-loops
Easy

Missing Number

Find the one number missing from 0..n.

You'll learn Arithmetic seriesSum difference trick
ArraysBeginnerStudent-beginnermath
Medium

K-th Smallest Element

Find the k-th smallest value without fully sorting.

You'll learn QuickselectPartitioning
AdvancedCompetitive-programmingSorting
Easy

Min and Max Together

Find the smallest and largest value in one pass.

You'll learn Single passMultiple return values
ArraysBeginnerFunctionsLearning-path

🌀 About This TypeScript Online Executor

The CodeUtility TypeScript Executor lets you write and run TypeScript code directly in your browser - no compiler setup, Node.js installation, or local environment required. It runs real TypeScript code compiled to JavaScript inside a secure, sandboxed runtime.

This environment currently supports TypeScript 5.4, giving you access to the latest language features such as decorators, improved type inference, and modern ECMAScript support.

Whether you're learning TypeScript, testing utility functions, or experimenting with typing and interfaces, this tool provides a fast and interactive way to write, compile, and execute your code with instant feedback.

It’s perfect for developers who want to explore TypeScript’s type system or verify how TypeScript compiles to JavaScript without switching between editors or local terminals.

More than a code runner

Use a multi-file editor, an isolated execution terminal, runtime-specific libraries, persistent workspaces, sharing, and real-time collaboration from the same executor.

How to use this executor?

Choose a runtime, open or create a file, write your code, and select Run. Output appears in the terminal, while signed-in users can keep files in a workspace, install libraries, and collaborate through shares.

  1. Select a version and edit the current file or open another workspace file.
  2. Run the code, provide input in the terminal when requested, and review saved run history.
  3. Use libraries, workspace tools, sharing, and chat when your task needs more than one snippet.

💡 TypeScript Basics Guide for Beginners

1. Declaring Variables

TypeScript allows static typing with let, const, and type annotations.

let x: number = 10;
const pi: number = 3.14;
let name: string = "Alice";
let isActive: boolean = true;

2. Conditionals (if / switch)

Use if, else if, and else for branching. switch handles multiple values.

let x = 5;
if (x > 0) {
  console.log("Positive");
} else if (x < 0) {
  console.log("Negative");
} else {
  console.log("Zero");
}

switch (x) {
  case 1:
    console.log("One");
    break;
  case 2:
    console.log("Two");
    break;
  default:
    console.log("Other");
}

3. Loops

Use for, while, and for...of for iteration.

for (let i = 1; i <= 5; i++) {
  console.log(i);
}

let i = 5;
while (i > 0) {
  console.log(i);
  i--;
}

4. Arrays

Use square brackets [] to define arrays.

let numbers: number[] = [1, 2, 3, 4, 5];
let names: string[] = ["Alice", "Bob"];
console.log(numbers[1]);

5. Array Manipulation

Use built-in methods like push, splice, and filter.

let arr = [10, 20, 30];
arr.push(40);          // Append
arr.splice(1, 1);      // Remove second element
console.log(arr);

6. Console Input/Output

Use console.log to display output in the console.

const name: string = "Alice";
console.log("Hello, " + name);

7. Functions

Declare functions with typed parameters and return values.

function add(a: number, b: number): number {
  return a + b;
}

console.log(add(3, 5));

8. Maps

Use plain objects or Map for key-value structures.

const m = new Map<string, number>();
m.set("Alice", 25);
console.log(m.get("Alice"));

9. Exception Handling

Use try and catch to handle errors.

try {
  throw new Error("Something went wrong");
} catch (e) {
  console.error(e.message);
}

10. File I/O (Node.js only)

Use Node.js fs module to read and write files.

import * as fs from "fs";

fs.writeFileSync("file.txt", "Hello File");
const content = fs.readFileSync("file.txt", "utf-8");
console.log(content);

11. String Manipulation

Use string methods like length, concat, includes.

let str = "Hello World";
console.log(str.length);
console.log(str + "!");
console.log(str.includes("World"));

12. Classes & Objects

TypeScript supports object-oriented programming.

class Person {
  name: string;
  constructor(name: string) {
    this.name = name;
  }
  greet() {
    console.log(\`Hi, I'm \${this.name}\`);
  }
}

const p = new Person("Alice");
p.greet();