Domain driven design and
type checking for JavaScript.

"Si vis pacem, para bellum"
(Vegetius 5th century)

The idea

What's a type? In tcomb a type is represented by a function T such that:

  1. has signature T(value) where value depends on the nature of T

  2. is idempotent, that is T(T(value)) = T(value)

  3. owns a static function returning true if x is an instance of T


  • immutability: instances are immutables in development mode
  • speed: asserts are active only in development mode and stripped in production code.
  • DDD: write complex domain models in a breeze and with a small code footprint
  • debugging: you can customize the behaviour when an assert fails leveraging the power of Chrome DevTools
  • runtime type introspection: every model written with tcomb is inspectable at runtime
  • JSON: encodes/decodes domain models to/from JSON for free