Online TypeScript Compiler
Check your types and run the code in one step. No tsconfig, no setup.
About this TypeScript compiler
This online TypeScript compiler uses TypeScript 5.0 on our server. It checks your types, turns the code into JavaScript, and runs it with Node.js. You see type errors and console.log output in the same place.
It is useful when you learn TypeScript, or when you want to test a type or a small function before you add it to a project.
How to use it
- Write TypeScript code in the editor. Use console.log() to print.
- Press Run. If a type is wrong, the compiler shows the error and the line.
- If there are no errors, the program runs and you see its output.
TypeScript examples
Open any of these from the Examples tab in the side bar.
Hello, World
const greeting: string = "Hello, World!";
console.log(greeting);
Typed function
function average(marks: number[]): number {
const total = marks.reduce((sum, m) => sum + m, 0);
return total / marks.length;
}
console.log(average([72, 85, 64]).toFixed(1));
Interface
interface Course {
title: string;
weeks: number;
}
const courses: Course[] = [
{ title: "Python Basics", weeks: 4 },
{ title: "React", weeks: 6 },
];
for (const c of courses) {
console.log(`${c.title}: ${c.weeks} weeks`);
}
What is TypeScript?
TypeScript is JavaScript with types. You write the type of a variable or a function argument, and the compiler checks every use of it before the code runs. Many mistakes are found while you write the code instead of in production.
Large web projects built with React, Angular and Node.js often use TypeScript. The browser does not run TypeScript directly; it is always compiled to JavaScript first.
Common errors and how to fix them
Type 'string' is not assignable to type 'number'The value has a different type from the one you declared. Change the value or the type.Property 'x' does not exist on type …The object type has no such field. Check the spelling or add the field to the type.Cannot find name 'require'Node.js type definitions are not installed here. Use plain TypeScript without Node modules.
Frequently asked questions
Which TypeScript version is used?
TypeScript 5.0. The compiled JavaScript runs on Node.js.
Do I need a tsconfig.json file?
No. Default settings are used, so you can start writing code at once.
Can I import npm packages?
No. Programs have no internet access, so only plain TypeScript code works.
Where is the plain JavaScript compiler?
Use the JavaScript compiler page. It runs JavaScript in your browser, which is faster.
Is it free?
Yes. It works without an account. A free account gives higher limits.
Other free compilers
Learn to code with DevHives
Step-by-step lessons, DSA problems with a judge and mock interviews — made for students in India.
Create a free account