Strict compiler baseline for libraries

Rule

tsconfig.build.json sets strict, noUncheckedIndexedAccess and exactOptionalPropertyTypes to true. Write code that passes them: check indexed access for undefined, and never assign undefined to an optional property unless its type includes it. Tool configs are protected; if a setting blocks a correct change, escalate instead of editing the config.

Do

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "strict": true,
    "noUncheckedIndexedAccess": true,
    "exactOptionalPropertyTypes": true,
    "declaration": true,
    "declarationMap": true,
    "sourceMap": true,
    "rootDir": "src",
    "outDir": "dist"
  },
  "include": ["src"]
}
export function firstTerm(terms: readonly string[]): string | undefined {
  const head = terms[0];
  return head === undefined ? undefined : head.toLowerCase();
}

Don’t

export function firstTerm(terms: readonly string[]): string {
  // terms[0] is string | undefined under noUncheckedIndexedAccess
  return terms[0].toLowerCase();
}

Rationale

strict alone lets array and record reads claim a value that may be missing. The two extra flags close the gaps that most often produce runtime undefined errors in small libraries. Source: the A7 package contract in Package Conventions.