Imported from jimmypaolini/codebase (
.agents/skills/write-typescript/SKILL.md). Install upstream withnpx skills add jimmypaolini/codebase --skill write-typescript. Copyright stays with the author (MIT).
Write TypeScript
All TypeScript projects in this codebase use strict settings. This skill is the entry point and links to focused reference files so guidance stays organized and maintainable.
When to Use This Skill
Use this skill when:
- Writing or refactoring
.tsor.tsxfiles - Fixing TypeScript compile or lint errors
- Reviewing strict-mode type-safety issues
- Standardizing naming, import style, or control-flow patterns
- Writing strict typed tests (including
fs.readdirSyncDirent mocks)
References
- Strict typing
: strict flags, explicit return types,
anyavoidance,unknown, promises, exhaustive switches. - Naming and imports
: identifier naming, abbreviation rules, type imports, NodeNext
.jsextensions. - Class and control flow : readonly properties, braces, early returns, object shorthand, template literals.
- Error handling and tests : catch typing, guard-first test narrowing, Node Dirent mock typing pattern.
Related Skills
Verification
After TypeScript changes:
pnpm exec nx run <project>:lint-codebase --configuration=write
pnpm exec nx run <project>:lint-codebase --configuration=check
Notes
- Keep this
SKILL.mdconcise and discovery-focused. - Add detailed examples and larger workflows to files under
references/. -
✅ Best practice: In NestJS class files such as
*.service.ts,*.command.ts,*.resolver.ts,*.dataloader.ts, and*.module.ts, keep only imports and the class at top level. Move helper types and interfaces to*.types.ts, constants to*.constants.ts, and shared initialization logic into class members or dedicated modules. -
⚠️ Warning: Do not use top-level alias exports or type re-exports from NestJS class files. Import supporting symbols from their source
*.types.tsor*.constants.tsfile instead of re-exporting them through the class file.