読み方のヒント
矢印ボタン(または ← → キー)でページを移動できます。
npx tsc --init で作られる tsconfig.json は、TypeScript 7.0 では次のような内容です(コメントの行を省いています。5.9 以降は同じ内容です)。
{
"compilerOptions": {
"module": "nodenext",
"target": "esnext",
"types": [],
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"strict": true,
"jsx": "react-jsx",
"verbatimModuleSyntax": true,
"isolatedModules": true,
"noUncheckedSideEffectImports": true,
"moduleDetection": "force",
"skipLibCheck": true
}
}
compilerOptions の中に、型チェックと変換の設定を書きます。項目は多くありますが、目的で分けると次の4つになります。
| 目的 | 主な項目 |
|---|---|
| どれくらい厳しく調べるか | strict、noUncheckedIndexedAccess、exactOptionalPropertyTypes |
| どの JavaScript にするか | target、module |
| どのファイルを調べるか | include、rootDir |
| 何を作るか | outDir、sourceMap、declaration、noEmit |
2 / 20