typescript-conventions
Installation
SKILL.md
TypeScript Conventions
Project-wide TypeScript standards that complement agent-specific instructions.
Type Safety
- No
any: Useunknownif the type is truly dynamic, then narrow. - Strict config:
strict: true,noUncheckedIndexedAccess,verbatimModuleSyntax. - Use
Readonly<T>,Pick,Omit, andRecordfor precise types. - Use branded types for entity IDs (e.g.,
UserId,OrderId) to prevent mixing. - Prefer
z.infer<typeof schema>over hand-written types when a Zod schema exists.
Interface vs Type
- Interfaces for object shapes that may grow — they support
extendsand declaration merging. - Type aliases for unions, intersections, mapped types, and complex compositions.
- Simple rule:
interfacefor plain objects,typefor everything else.