All articles
5 min read2024-03-08

The Power of Type Systems

Why TypeScript changed the way I think about code, and why you should care.

I resisted TypeScript for longer than I should have. It felt like bureaucracy — writing types for things I already knew. The moment I stopped seeing types as overhead and started seeing them as documentation that can't go out of sync, everything clicked.

Types as Communication

When you write a function signature in TypeScript, you're not just telling the compiler what to expect — you're telling the next developer (often future you) what this function does. The type system encodes your intent in a way that comments never can, because types are verified.

Catching Errors Before Runtime

The ROI on TypeScript shows up most clearly in large codebases and refactors. When I rename a field or change a function signature, TypeScript finds every callsite that needs updating. No more hunting through logs for runtime errors that should have been caught statically.

The Right Level of Strictness

Start with strict mode from the beginning. It's harder to retrofit later. Use unknown instead of any — it forces you to narrow the type before using it. Use discriminated unions instead of boolean flags. These habits compound over time into codebases that are genuinely easier to reason about.