What programmer hasn't at some point in their career written code like this: throw new Error(`Unexpected value: ${value}. This should never happen!`); ...and then had a user submit a bug report containing that very message. The `never` type is a nice way to model those scenarios and hopefully avoid such an error ever being seen by the user. // Compile error unless we've ruled out // `value` at the type level assertNe…
The first one is a very useful error as a user though. It tells me the unexpected value isn't my fault and I should go report a bug.
Typescript's practicality here does let you walk and chew bubblegum. This sort of stuff is super practical for UI development, because ultimately at the interfaces with servers you're likely to make some assumptions about incoming data, and so you'll have that fundamental cast in your code from any to Foo, and this sort of error will be reportable.