AIStorageDepot
← Prompt library

TypeScript Project Rules

Rule · Standards · #standards #typescript #agents-md

TypeScript Rules

Types

  • strict: true stays on. Never weaken tsconfig to silence an error.
  • No any — use unknown and narrow it. If any is truly unavoidable, comment why.
  • Model states with discriminated unions instead of grab bags of optional fields.
  • Let inference work: annotate function boundaries, skip obvious locals.

Code

  • async/await over promise chains; no floating promises — await them or void them explicitly.
  • Handle errors at the boundary that can act on them; never swallow a catch.
  • Prefer small pure functions; isolate side effects (IO, network, time) so they're easy to mock.
  • Exports are the API: export the minimum, keep helpers module-private.

Style

  • Names reveal intent (retryDelayMs, not d). Booleans read as questions (isReady).
  • No magic values — name constants once, where they're defined.
  • Delete dead code — the repo's history remembers it for you.

This is one of dozens of free prompts in the AIStorageDepot library. Sign up free to save them, version them, and pull them straight into Claude, Cursor, or VS Code over MCP.