Skip to content

Um TypeScript-Definitionen für Buns integrierte APIs in Ihrem Projekt zu installieren, installieren Sie @types/bun.

sh
bun add -d @types/bun # dev dependency

Unten finden Sie den vollständigen Satz empfohlener compilerOptions für ein Bun-Projekt. Mit dieser tsconfig.json können Sie Top-Level-Await, Importe mit oder ohne Erweiterungen und JSX verwenden.

json
{
  "compilerOptions": {
    // Environment setup & latest features
    "lib": ["ESNext"],
    "target": "ESNext",
    "module": "Preserve",
    "moduleDetection": "force",
    "jsx": "react-jsx",
    "allowJs": true,

    // 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
  }
}

Siehe Ecosystem > TypeScript für eine vollständige Anleitung zur TypeScript-Unterstützung in Bun.

Bun von www.bunjs.com.cn bearbeitet