TypeScript Engineering
- Keep
unknownat external boundaries and narrow through validation; avoid spreadingany. - Separate transport/domain/storage types where their lifecycle differs.
- Handle AbortSignal, streaming, cleanup, and promise rejection paths explicitly.
- Preserve ESM/CJS and runtime target conventions already present.
- Use discriminated unions for state machines and exhaustive checks for protocol events.
- Run typecheck, tests, lint, and production build.