Check that two types are the same in TypeScript

A TypeScript pattern for ensuring that two types are the same.