TypeScript Standard

TypeScript Standard

Non-Negotiables

  1. Airbnb + typescript-eslint define style and correctness.
  2. strict: true is the baseline.
  3. Types are documentation. If it’s ambiguous, it’s broken.
  4. Runtime validation for external inputs is mandatory. Types do not protect you at runtime.

Minimum Requirements (Industry Standard Baseline)

Formatting & Linting

  • Format with Prettier.
  • Lint with ESLint + @typescript-eslint.
  • CI must fail on lint/type errors.

Type Safety

  • Enable strict (and keep it on).
  • Avoid any. Prefer unknown + narrowing.
  • No non-null assertions (!) unless proven safe and documented.

Error Handling

  • Never ignore rejected promises.
  • Use explicit error boundaries (API layer, worker handler, job runner).
  • Provide stable error codes for API consumers.

API & Data Validation

  • Validate external inputs (HTTP payloads, queue messages, env vars).
  • Prefer schema validators (e.g. Zod/Yup/Joi) and keep schemas close to boundaries.

Dependency Hygiene

  • Pin critical dependencies.
  • No unused dependencies; no dead code.

References