0003. TypeScript: strict, native ESM, version 6.0

Design document, published from the repository at docs/adr/0003-typescript-configuration.md.

  • Status: Accepted
  • Date: 2026-11-13

Context

Type errors in identity and credential handling are security bugs. The codebase targets Node.js 26 and modern browsers.

Decision

  • tsconfig.base.json enables strict plus noUncheckedIndexedAccess, exactOptionalPropertyTypes, noImplicitOverride, noPropertyAccessFromIndexSignature, noUnused* and verbatimModuleSyntax.
  • All packages are native ESM with module/moduleResolution: NodeNext; Next.js uses Bundler resolution as it requires.
  • types: [] by default — packages opt in to @types/node explicitly, so browser-safe code cannot accidentally use Node APIs.
  • any is banned by lint (no-explicit-any); an exception requires an inline disable comment with a justification.
  • TypeScript is pinned to ~6.0. TypeScript 7 (native compiler) is released, but typescript-eslint, which provides our type-aware lint rules, supports <6.1 only. Upgrade when it adds support.
  • NestJS decorator metadata is enabled only in apps/api; its tests compile through SWC because the default Vitest transformer cannot emit decorator metadata.

Consequences

Stricter code at the cost of some verbosity (e.g. declaring ProcessEnv keys). The TS 7 upgrade is tracked as a follow-up.