Is TypeScript compiled or interpreted?
TypeScript is compiled to JavaScript, and the JavaScript is then compiled and optimized by an engine such as V8. TypeScript itself adds no speed and costs none at run time, because the compiler erases the types.
How it runs your code
The TypeScript compiler, tsc, checks your types and emits JavaScript. The types do not reach the running program. A JavaScript engine then runs the output, and V8 compiles each function to bytecode and hot code to machine code. Deno and Bun run TypeScript files directly by stripping the types first.
Does that make TypeScript slow?
TypeScript's speed is JavaScript's speed. We measured our program as TypeScript on Node 22, so the V8 numbers below are the TypeScript numbers.
What we measured
One small program, an order with items, a coupon, a discount and tax, written as an average programmer would write it. Times are nanoseconds per call.
| Setting | Class code | Plain functions |
|---|---|---|
| JIT off (--jitless) | 1,699 | 856 |
| Optimizing compilers off (--no-opt) | 1,226 | 587 |
| Default | 124 | 99 |
Measured with mitata, one process per setting, so there is no spread figure. See the JavaScript page for the comparison with C++ and Go.
Questions
Is TypeScript interpreted?
No. It is compiled to JavaScript, and the JavaScript engine compiles and optimizes that code.
Do types make TypeScript code faster?
No. The compiler erases types, so the running program does not see them.
Can I run TypeScript without compiling it first?
Deno and Bun run TypeScript files directly. They strip the types and run the JavaScript that remains.
Related
Is JavaScript compiled? · Is Kotlin compiled? · Is Java compiled? · Compiled vs interpreted · Why optimization decides speed