Remove a bunch of exception throws in favor of type casts in TypeScript and remove some type assertions as well that TypeScript should uphold.