Running TypeScript in Deno
What you'll learn: How Deno runs TypeScript files natively without any compilation step.
The Build-Step-Free Experience
Remember how with Node.js you needed to use tsc, ts-node, or tsx to run TypeScript? Deno takes a completely different approach: it understands TypeScript out of the box.
Think of it like this: if Node.js is a car that needs a special adapter to play your music format, Deno is a car with that format already built into the stereo system. You just plug and play.
How It Works
With Deno, you simply write a .ts file and run it directly:
// hello.ts
const greeting: string = "Hello from Deno!";
console.log(greeting);
Then execute it with:
deno run hello.ts
That's it. No tsc compilation step. No ts-node wrapper. No build tool configuration. Deno compiles TypeScript to JavaScript internally and caches the result, so subsequent runs are fast.
Importing TypeScript Files
You can even import other TypeScript files directly:
// math.ts
export function add(a: number, b: number): number {
return a + b;
}
// main.ts
import { add } from "./math.ts";
console.log(add(2, 3));
Notice the .ts extension in the import—Deno requires explicit file extensions, which actually makes your dependencies clearer.
Key Takeaway: Deno eliminates the entire build toolchain for TypeScript by supporting .ts files natively, making it the most frictionless way to run TypeScript code directly.