User-defined type guards in TypeScript
gcollazo.com