Script Raccoon @scriptraccoon.dev · Nov 17

Can someone explain to me this TypeScript error? The compiler already knows that the branch in the end never runs, so why does it still complain that it does not always return? Is this a bug or limitation of TypeScript? 🤔

3 likes 1 replies

?

Replies

Script Raccoon · Nov 17

I've actually had this issue here, a function that converts boolean expressions to strings. I don't want to omit the last operator check, even though it's the only possible case left: it breaks the symmetry of the code, and it is awkward. But with the check, TypeScript fails, and I need to throw.