Programmers use type systems to prevent errors in their programs, but precisely which behaviors should be considered erroneous varies from programmer to programmer. Indeed, the flexibility of JavaScript makes it essentially futile to design a single type system that is flexible enough for all purposes; instead, we need multiple, related type systems that can be customized for each programmer.
Our implementation takes advantage of OCaml's functor system, and
provides a Base type system module with typical types
and typing rules, and hooks for an Extension module to
extend the Base with new types and typing rules.
The TeJaS system is summarized in our paper at DLS
2013.
We've used TeJaS to implement a type system for
jQuery, which augments the Base system with new
kinds for describing the sizes of jQuery collection objects.
TeJaS is open-source and available on Github.