# TypeScript Standards

Extends common coding standards with TypeScript-specific rules.

## Compiler Configuration

- `strict: true` always — no exceptions
- `noUncheckedIndexedAccess: true`, `exactOptionalProperties: true`

## Type Safety

- No `any` — use `unknown` and narrow
- `interface` for object shapes, `type` for unions/intersections/computed
- Discriminated unions over type guards: `{ ok: true; data: T } | { ok: false; error: E }`

## Runtime Validation

- Zod (or similar) at system boundaries: API bodies, env vars, config
- Parse external data into typed structures — never trust raw input

## Module Organization

- Barrel exports (`index.ts`) for public APIs; internals not exported
- One responsibility per file, co-locate tests

## Modern TypeScript

- `as const` for literal types, `satisfies` for type-safe inference
- Template literal types for string patterns
- `Map`/`Set` over plain objects for dynamic keys

## Error Handling

- Typed Result types over try/catch where possible
- Catch at boundaries, not every function
- Never catch and ignore — handle, transform, or re-throw

## Naming

- Interfaces/Types: PascalCase (no `I` prefix)
- Enums: PascalCase members
- Constants: UPPER_SNAKE_CASE for true constants
