Also note that, at least with Flow and TypeScript, type information isn't guaranteed to be correct, so it's a bit dangerous to do type-based optimizations (although tools certainly could try, with the caveat that if your types are wrong, your code may break even more than it otherwise would).