clean-typescript
Clean TypeScript
We use TypeScript as a correctness and clarity tool, not as ceremony. Types should reduce bugs and cognitive load.
Type Philosophy
- PREFER explicit, readable types over clever or overly generic ones
- AVOID
anyand unsafe type assertions - Use
unknowninstead ofanywhen necessary - Let TypeScript infer types when inference is clear and stable
Types & Interfaces
- PREFER
typealiases for most use cases - Use
interfaceprimarily for public, extendable object shapes - Keep types small, composable, and well-named
Functions & APIs
- PREFER explicit return types for public functions
- Avoid function overloads unless they meaningfully improve the API
- Keep function signatures simple and predictable
Nullability & Safety
- Handle
nullandundefinedexplicitly - DO NOT rely on non-null assertions (
!) except as a last resort - Prefer narrowing via control flow and guards
Enums & Constants
- AVOID
enum - PREFER union types or
as constobjects - Keep runtime output predictable and minimal
Error Handling
- Type errors and error states explicitly
- Prefer result objects or typed errors over throwing where appropriate
- Do not hide failure modes behind broad types
General Principles
- Types should explain intent
- If a type is hard to understand, it’s probably wrong
- Favor maintainability over theoretical completeness
More from neversight/skills_feed
ai-image-generation
|
7react-best-practices
Provides React patterns for hooks, effects, refs, and component design. Covers escape hatches, anti-patterns, and correct effect usage. Must use when reading or writing React components (.tsx, .jsx files with React imports).
7ui-designer
Use when user needs visual UI design, interface creation, component systems, design systems, interaction patterns, or accessibility-focused user interfaces.
7python-env
Fast Python environment management with uv (10-100x faster than pip). Triggers on: uv, venv, pip, pyproject, python environment, install package, dependencies.
7typescript-best-practices
Provides TypeScript patterns for type-first development, making illegal states unrepresentable, exhaustive handling, and runtime validation. Must use when reading or writing TypeScript/JavaScript files.
6ai-marketing-videos
|
6