Skip to content

Parse, Don't Validate — In a Language That Doesn't Want You To

6.9 relevance
Score Breakdown
technical depth
8
novelty
6
actionability
7
community
6
strategic
5
personal
8

Scored daily by a customisable AI persona to surface the most relevant engineering leadership news.

Strong software design principle with practical implementation advice, highly relevant to engineering.

General cekrem.github.io
Parse, Don't Validate — In a Language That Doesn't Want You To
Summary

TypeScript's structural typing undermines the 'parse, don't validate' principle by letting validators discard type information after runtime checks, forcing scattered re-validation. Branded types with unique symbols offer a workaround to encode parsed invariants (e.g., EmailAddress) into the type system, but the language provides no ergonomic support like Haskell's newtype or Elm's opaque types. The post demonstrates how to implement this pattern in TypeScript to make invalid states unrepresentable, though it requires deliberate discipline and boilerplate.

Author

Christian Ekrem