Strange Loop

Understanding TypeScript's Structural Type System

I was wrong. I thought TypeScript was something like a Java-ey type system layered atop JavaScript, bringing a dose of brittleness and losing the flexibility I appreciated about the warty-yet-ubiquitous multi-paradigm language.

But that's not it at all! TypeScript radically improves the JavaScript development experience by providing a flexible, light-weight type system for modern EcmaScript. It does so while maintaining a delicate balance: adding a way to enforce assumptions and invariants without removing the flexibility prized by dynamic language developers. This works because TypeScript's type system is structural and not nominal - that is, based on shapes of data instead of identities of types.

Come see what's cool and exciting about TypeScript's defining feature. We'll show what differentiates a structural type system from a nominal one; how key features of TypeScript provide a powerful language to express invariants about your system; and how TypeScript leverages its knowledge of what code implies about the shapes of data to avoid most of the type system nuisances that put some developers off of statically typed languages.

Drew Colthorp

Drew Colthorp

Atomic Object

Drew Colthorp has been exploring ways to make JavaScript less painful since he learned how to program with it almost 20 years ago. (IE4 FTW!) As Principal Developer and Consultant at Atomic Object, he has led or consulted on development of unreasonably many web apps over the past 12 years.