best-practice-ts
best-practice-ts
This skill is the TypeScript layer. It assumes best-practice-js is already
applied underneath — every rule about const/let, destructuring, arrow
functions, module syntax, control flow, naming, and so on still holds. This
document does not restate those rules. It only covers what changes, or gets
added, once a file has a type system: tsconfig.json, the type system
itself (unions, generics, narrowing, mapped/conditional types), declaration
files, and the runtime-validation boundary that TypeScript cannot enforce for
you.
Target: TypeScript 5.4+. All examples assume strict: true and the
tsconfig.json baselines in Chapter 1.
All code honors the user's Prettier config: no semicolons at statement end,
single quotes, 2-space indent, no trailing commas, parenthesized single arrow
params, double quotes only in JSX attributes. Semicolons do appear between
members inside interface/type object bodies — Prettier leaves those alone.