typescript-conventions
TypeScript code conventions covering strict tsconfig, ESM imports, discriminated unions, formatting/linting, Vitest testing, lockfile-based packaging, Node.js, and security. Load when writing or revie
Files1
View on GitHubSKILL.mdinternal/builtins/languages/typescript/skills/typescript-conventions/SKILL.md
GitHubstrict: true+noUncheckedIndexedAccessin tsconfig, neverany— useunknownwith type guards.- ESM imports only,
constoverlet,as constfor literals,interfaceovertypefor objects. import typefor type-only imports to avoid runtime overhead. Discriminated unions for type-safe state.- Formatting/linting: a formatter + linter (e.g., Prettier + ESLint, or Biome). Type checking:
tsc --noEmitin CI. - Testing: a fast test runner (e.g., Vitest or Jest), 80%+ coverage. Runtime validation at system boundaries with a schema validator (e.g., Zod).
- Error handling: discriminated unions for expected errors, throw only for unexpected.
- Package manager: a lockfile-based package manager (npm, pnpm, or yarn) with the lockfile committed, build: a bundler (e.g., tsup or esbuild).
- Monorepo: workspace protocol (
workspace:*), shared tsconfig base, a workspace manifest (e.g.,pnpm-workspace.yaml). - Node.js:
node:prefix for core modules,fetchoveraxios. - Security:
npm audit/pnpm auditfor dependency CVE scanning. Zero tolerance for critical/high vulnerabilities. - Anti-patterns: non-null assertions (
!), type assertions (as),enum(use unions),@ts-ignore.