
Stop Reaching for any: Narrowing unknown in TypeScript
Why unknown is the type-safe replacement for any, and the narrowing patterns that make it practical in real code.
Categories
Software craft & practices · 55 articles · Page 1 of 5

Why unknown is the type-safe replacement for any, and the narrowing patterns that make it practical in real code.

Why most async TypeScript code ignores cancellation entirely, and how to build composable, leak-free cancellation with AbortController.

Use TypeScript template literal types to encode event names, route patterns and permission sets in the type system — no runtime checks, no string drift.

The satisfies operator validates that a value matches a type while preserving literal inference — why that distinction matters and where to apply it.

Eliminate a whole class of runtime bugs by teaching TypeScript the difference between a UserId and an OrderId — even when both are strings underneath.

TypeScript's type system stops at compile time — Zod closes the gap by validating data at the runtime boundaries where it actually matters.

Move beyond try-catch soup: discriminated unions, Result types, and error boundaries that make TypeScript codebases more reliable and maintainable.

A practical guide to a testing strategy that catches real bugs: unit, integration and end-to-end with Vitest, Testing Library and Playwright.

Advanced TypeScript patterns I use daily: discriminated unions, branded types, the builder pattern and utility types that keep large codebases safe.

Dependency injection in TypeScript with constructor injection, factory functions, DI containers and module composition — testable, without framework lock-in.

A battle-tested framework for diagnosing and resolving production incidents quickly — from first alert to root cause analysis and prevention.

Trunk-based development in monorepos: code ownership, selective CI triggers, merge queues and branch protection for hundreds of developers in one repo.