Here, we have a function that has an infinite loop, and hence, never returns. TypeScript automatically infers the return type of such a function as never. Similarly, if a function always throws, then again, TypeScript infers the return type of such a function to be never.
Also, if during code flow analysis, you end up with a condition that can never be true, TypeScript infers the type never. There is never any value in a never variable, and any attempt to add one will result in an error. You can use this to do exhaustive checks in union types.
Later, if you need to add another type to the union, for example, a Boolean, you will now get nice errors at all the places where the new type was not handled, because only a never is assignable to a never. Now, if you go ahead and add another typeof to handle this new case, the error goes away.