Skip to main content
To get TypeScript definitions for Bun’s built-in APIs, install @types/bun.
terminal
You can now reference the Bun global in your TypeScript files without errors in your editor.

Suggested compilerOptions

Bun supports top-level await, JSX, and imports with .ts extensions, which TypeScript doesn’t allow by default. Use these compilerOptions in a Bun project so TypeScript doesn’t warn about those features.
tsconfig.json
Running bun init in a new directory generates this tsconfig.json for you.
terminal

TypeScript 6 and 7

If you’re using TypeScript 6.0 or later, you also need "types": ["bun"] in your compilerOptions. See TypeScript 6 and 7.