Using Bun’s Zero‑Configuration TypeScript Support for Faster Development
Learn how Bun’s built‑in TypeScript transpiler lets you run .ts files instantly, eliminating a separate compile step while noting its current limitations.
02 May 2026, 19:43 UTC

When you start a new project, waiting for a TypeScript compiler to finish before you can see any output slows down the feedback loop. Bun removes that step by transpiling .ts files on the fly, letting you run type‑safe code instantly.
The Problem: Waiting for a Build Step
Traditional workflows require a separate tsc or Babel step to turn TypeScript into plain JavaScript. Even with watch modes, each change triggers a compile pass that can add noticeable latency, especially in larger codebases.
How Bun Handles TypeScript On‑The‑Fly
Bun bundles a fast JavaScriptCore‑based transpiler that parses TypeScript syntax, strips type annotations, and emits executable JavaScript directly in memory. Because the transpiler is part of the runtime, there is no extra dependency to install. Source maps are generated automatically so debuggers can map back to the original .ts lines.
Worked Example: Running a TypeScript Script
- Open a terminal in an empty directory.
- Run
bun init -yto create a minimalpackage.json. No special permissions are needed. - Create a file named
index.tswith the following content:function add(a: number, b: number): number { return a + b; } console.log(add(2, 3)); - Execute the script with
bun run index.ts. The command runs in the current user context; no elevated privileges are required. - Check the process exit code (
echo $?on Unix‑like systems) – it should be 0, indicating successful execution. - To confirm that a source map was produced, run
bun --debug index.tsand look for a.mapfile alongside the output or verify that a debugger can break on the original TypeScript line.
These steps demonstrate that Bun can execute TypeScript without a prior tsc call, and the extra transpilation time is typically under a millisecond for small files.
Trade‑Offs and Limitations
Bun’s transpiler implements a subset of TypeScript features. Advanced constructs such as const‑only enums, namespaces, or certain decorator metadata may be omitted or behave differently compared to the official tsc compiler. Because type checking occurs at runtime, type errors are only surfaced when the offending code is executed, which can allow faulty code to pass static linting until it runs.
To verify that a particular TypeScript feature works as expected, write a small test case that uses the feature, run it with bun run, and observe whether the behavior matches your expectations. If you encounter unexpected results, consider filing an issue on Bun’s repository or using tsc for a full type‑check in your CI pipeline.
What to Do Next
If you are starting a new service or script, try initializing a project with bun init -y and write your entry point in TypeScript. Keep an eye on the console for any runtime type errors, and use bun --debug when you need source‑map‑backed debugging. For projects that require the full TypeScript type‑system, retain tsc in your CI while still benefiting from Bun’s fast startup during local development.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.