Skip to content

日本語

@yuu1111/tsconfig ​

Shared TypeScript configurations.

Install ​

bash
bun add -D @yuu1111/tsconfig

Usage ​

Extend one preset in tsconfig.json and add the paths it leaves to the project.

json
{
  "extends": "@yuu1111/tsconfig/base.json",
  "include": ["src/**/*.ts"]
}

Presets ​

PresetExtendsUse case
base—Strict baseline shared by the other presets
bunbaseAdds the Bun global types
librarybaseEmits JavaScript with declarations and source maps
declaration-onlylibraryEmits declaration files only
reactbaseAdds the DOM types and the JSX transform

base ​

Every other preset extends base. It checks types without emitting, and leaves the emit to the preset or the bundler.

OptionValue
targetESNext
lib["ESNext"]
modulePreserve
moduleResolutionbundler
moduleDetectionforce
stricttrue
noEmittrue
isolatedModulestrue
verbatimModuleSyntaxtrue
esModuleInteroptrue
resolveJsonModuletrue
skipLibChecktrue
forceConsistentCasingInFileNamestrue
noUncheckedIndexedAccesstrue
noFallthroughCasesInSwitchtrue
exactOptionalPropertyTypestrue
json
{
  "extends": "@yuu1111/tsconfig/base.json"
}

bun ​

Adds types: ["bun"]. Install @types/bun in the project.

json
{
  "extends": "@yuu1111/tsconfig/bun.json"
}

library ​

Turns emit on and writes declarations, declaration maps, and source maps.

OptionValue
noEmitfalse
declarationtrue
declarationMaptrue
sourceMaptrue
json
{
  "extends": "@yuu1111/tsconfig/library.json",
  "compilerOptions": {
    "rootDir": "src",
    "outDir": "dist"
  },
  "include": ["src/**/*.ts"]
}

declaration-only ​

Extends library and sets emitDeclarationOnly, for a build where a bundler emits the JavaScript.

json
{
  "extends": "@yuu1111/tsconfig/declaration-only.json",
  "compilerOptions": {
    "rootDir": "src",
    "outDir": "dist"
  },
  "include": ["src/**/*.ts"]
}

react ​

Adds DOM and DOM.Iterable to lib and sets jsx: "react-jsx".

json
{
  "extends": "@yuu1111/tsconfig/react.json",
  "compilerOptions": {
    "outDir": "dist"
  }
}