Bun, Request, or other globals from @types/bun, here’s how to fix it.
What changed
Starting in TypeScript 6.0, thetypes field in compilerOptions defaults to an empty array instead of including all @types/* packages. You now need to explicitly list the type packages you use.
Add "types": ["bun"] to your tsconfig
In your tsconfig.json, add "types": ["bun"] to compilerOptions:
tsconfig.json
@types/bun. If you use other @types/* packages, include them too:
tsconfig.json
@types/bun installed — the types option tells TypeScript which packages to include, but the package itself must exist in node_modules:
terminal
Full recommended tsconfig.json
Here’s the full recommendedtsconfig.json for a Bun project using TypeScript 6.0 or later:
tsconfig.json
Does this apply to TypeScript 7?
Yes. TypeScript 7 carries forward the same default. If you’re upgrading directly from TypeScript 5 to 7, the same fix applies — add"types": ["bun"] to your compilerOptions.