TypeScript 6 and 7 - BunDocumentation Index Search...⌘KInstall Bun Search...Navigation Get Started TypeScript 6 and 7RuntimePackage ManagerBundlerTest RunnerGuidesReferenceBlogFeedback:first-child]:!hidden peer-[.is-custom]:[&>:first-child]:sm:!hidden peer-[.is-custom]:[&>:first-child]:md:!hidden peer-[.is-custom]:[&>:first-child]:lg:!hidden peer-[.is-custom]:[&>:first-child]:xl:!hidden">Get StartedWelcome to BunInstallationQuickstartTypeScriptTypeScript 6 and 7bun initbun createCore RuntimeBun RuntimeWatch ModeDebuggingREPLbunfig.tomlFile & Module SystemFile TypesModule ResolutionJSXAuto-installPluginsFile System RouterHTTP serverServerRoutingCookiesTLSError HandlingMetricsNetworkingFetchWebSocketsTCPUDPDNSData & StorageCookiesFile I/OStreamsBinary DataArchiveSQLSQLiteS3RedisConcurrencyWorkersProcess & SystemEnvironment VariablesShellSpawnWebViewCronInterop & ToolingNode-APIFFIC CompilerTranspilerUtilitiesCSRF ProtectionSecretsConsoleTOMLYAMLMarkdownJSON5JSONLHTMLRewriterImageHashingGlobSemverColorUtilsStandards & CompatibilityGlobalsBun APIsWeb APIsNode.js CompatibilityContributingRoadmapBenchmarkingContributingBuilding WindowsBindgenLicense On this pageWhat changedAdd "types": ["bun"] to your tsconfigFull recommended tsconfig.jsonDoes this apply to TypeScript 7?Get StartedTypeScript 6 and 7 Copy pagespan]:line-clamp-1 overflow-hidden group flex items-center py-0.5 gap-1 text-sm text-gray-950/50 dark:text-white/50 group-hover:text-gray-950/70 dark:group-hover:text-white/70 rounded-none rounded-r-xl border px-3 border-gray-200 aspect-square dark:border-white/[0.07] bg-background-light dark:bg-background-dark hover:bg-gray-600/5 dark:hover:bg-gray-200/5" aria-label="More actions" type="button" id="radix-_R_n4ctdbsnlht5lebsnpfdb_" aria-haspopup="menu" aria-expanded="false" data-state="closed"> *]:[overflow-wrap:anywhere]"> Copy pagespan]:line-clamp-1 overflow-hidden group flex items-center py-0.5 gap-1 text-sm text-gray-950/50 dark:text-white/50 group-hover:text-gray-950/70 dark:group-hover:text-white/70 rounded-none rounded-r-xl border px-3 border-gray-200 aspect-square dark:border-white/[0.07] bg-background-light dark:bg-background-dark hover:bg-gray-600/5 dark:hover:bg-gray-200/5" aria-label="More actions" type="button" id="radix-_R_1cctdbsnlht5lebsnpfdb_" aria-haspopup="menu" aria-expanded="false" data-state="closed"> TypeScript 6.0 changed how type definitions are discovered. If you’ve upgraded TypeScript and your editor no longer recognizes Bun, Request, or other globals from @types/bun, here’s how to fix it.
What changed
Starting in TypeScript 6.0, the types 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 Yes NoSuggest editsRaise issueTypeScriptPreviousbun initNext⌘I xgithubdiscordyoutubePowered byThis documentation is built and hosted on Mintlify, a developer documentation platform
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
Skip to main contentBun home pageHow to configure Bun’s type definitions for TypeScript 6.0 and 7.0, which no longer auto-discover @types packages. Fix ‘Cannot find name Bun’ and other missing type errors after upgrading TypeScript.
{
"compilerOptions": {
"types": ["bun"],
},
}
This tells TypeScript to load type definitions from @types/bun. If you use other @types/* packages, include them too:
tsconfig.json{
"compilerOptions": {
"types": ["bun", "react"],
},
}
You still need @types/bun installed — the types option tells TypeScript which packages to include, but the package itself must exist in node_modules:
terminalbun add -d @types/bunFull recommended tsconfig.json Here’s the full recommended tsconfig.json for a Bun project using TypeScript 6.0 or later: tsconfig.json
{
"compilerOptions": {
// Environment setup & latest features
"lib": ["ESNext"],
"target": "ESNext",
"module": "Preserve",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,
"types": ["bun"],
// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false,
},
}
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.Was this page helpful?
TypeScript 6 and 7 - Bun,AI智能索引,全网链接索引,智能导航,网页索引
- How to configure Bun