Article summary
I'm super excited to be giving a talk about TypeScript at Strange Loop this year! The talk, “Understanding TypeScript's Structural Type System,” covers some of the deeper and most exciting ideas at the heart of TypeScript's namesake feature.
You can get an overview from the slides. (I'll post a link to the video once it's up.) The talk focuses on three main concepts:
- Structural typing and thinking about types as sets of values meeting a set of requirements
- Control-flow based type analysis, in which TypeScript can prove properties statically about your code by looking at your
if
andswitch
statements. - Type-level programming in TypeScript, where we see a few key language features that amount to a small functional programming language that runs in the type checker – as part of your editor's IDE features or the TypeScript compilation process.
Learning TypeScript
If you'd like to get a little hands-on experience with TypeScript's type system, fellow Atom Rachael McQuater and I have a workshop that's designed to be largely self-guided. Like the talk, it focuses most on leveraging TypeScript's type system, however it doesn't get into type-level programming.
I'd also recommend the TypeScript handbook at typescriptlang.org.
We also maintain a Single-Page App Starter Kit for internal use at Atomic that makes heavy use of TypeScript, React, GraphQL, and code generation to tie the three together. To see a non-empty example, check out the example-munchit branch. You can find more info here.
TypeScript Writing at Atomic
For more info about TypeScript's type system, check out these posts:
- Flavoring: Flexible Nominal Typing for TypeScript
- Understanding and Embracing TypeScript’s “readonly” by Matt Behrens
- Modular, Type-safe Metadata with TypeScript
For functional programming patterns in TypeScript:
- Small, Simple, Functional Lenses for TypeScript
- Simple Error Either in TypeScript by Shawn Anderson
- A Simple, Functional Module Pattern for TypeScript
- Understanding and Embracing TypeScript’s “readonly” by Matt Behrens
Or for using TypeScript with React or Redux: