Instruction file imported from juninmd/vibe-code (
.github/instructions/typescript-standards.instructions.md). Copyright stays with the author.
Rule: TypeScript Standards
1. Type Safety
- No
any: The use ofanyis strictly prohibited. Useunknownif the type is truly not known ahead of time, and use type guards to narrow it down. - Explicit Returns: Always declare return types for functions and methods to prevent unintended return values.
- Strict Null Checks: Always handle
nullandundefinedexplicitly. Use optional chaining (?.) and nullish coalescing (??).
2. Type Declarations
- Interfaces over Types: Prefer
interfacefor object shapes as they are more extensible. Usetypefor unions, intersections, and utility types. - Enums: Avoid
enum; prefer union types (e.g.,type Status = 'open' | 'closed') or constant objects (as const).
3. General Practices
- Prefer
readonlyfor properties that should not be mutated. - Ensure all parameters in public APIs are typed.