Use this skill for any non-trivial .ts or .tsx change.
Type Design
- Model the domain explicitly. Do not hide weak modeling behind
any, wide assertions, or
optional-everything objects.
- Prefer
unknown over any at trust boundaries, then narrow deliberately.
- Use interfaces for extendable object contracts. Use type aliases for unions, intersections, mapped
types, and conditional types.
- Prefer discriminated unions over boolean flag combinations.
- Keep shared types close to the code that owns them unless multiple modules genuinely depend on
them.
- Make impossible states impossible when the data model allows it.
Functions and APIs
- Give exported functions explicit parameter and return contracts.
- Use overloads only when they improve the public API. Otherwise prefer a single well-modeled input
object.
- Prefer result shapes and typed domain errors over vague thrown strings.
- Use early returns to keep control flow shallow.