Skip to main content
Bun’s runtime includes a built-in TypeScript transpiler. When you run a .ts or .tsx file, Bun strips the types on the fly and executes the resulting JavaScript — all in the same process, with no intermediate files written to disk.
Bun transpiles TypeScript but does not type-check it. Type errors in your editor will not prevent execution. Use bunx tsc --noEmit (see below) to run type checking separately.

Install type definitions

To get Bun.* globals and module types in your editor, install the @types/bun package:
After this, you can reference Bun.serve, Bun.file, and all other Bun APIs in TypeScript without seeing “Cannot find name ‘Bun’” errors. If you initialized your project with bun init, @types/bun is already installed and configured. Bun supports features that TypeScript’s default settings don’t allow — top-level await, importing .ts files by extension, and more. The following tsconfig.json is recommended for Bun projects:
tsconfig.json
bun init generates this file automatically. The key settings are:

Type checking

Bun does not type-check your code at runtime. To catch type errors, run the TypeScript compiler in check-only mode using bunx:
bunx downloads and runs typescript from npm without permanently installing it. If you already have TypeScript installed as a dev dependency, you can use it directly:
You can add this as a package.json script and run it in CI:
package.json

Path aliases

Bun reads paths from your tsconfig.json and uses them for module resolution. This means path aliases you configure for TypeScript also work at runtime — no separate bundler config needed.
tsconfig.json
With this config, the following import resolves to src/utils/format.ts at runtime:

JSX

Bun supports .jsx and .tsx files out of the box using the same transpiler. The JSX transform is controlled by the "jsx" field in tsconfig.json.
tsconfig.json
To use a different JSX runtime (such as Preact or Solid), set "jsxImportSource":
tsconfig.json
No Babel or other transform tools are required. Bun handles all of this natively.

TypeScript 6 and later

TypeScript 6.0 changed how @types/* packages are loaded. If you are using TypeScript 6.0 or later, explicitly include "types": ["bun"] in your compilerOptions to ensure Bun’s global declarations are loaded:
tsconfig.json