Introduction
TypeScript supports bottom types1. Cases where this occurs:
- A function never returns (e.g. if the function body has src_js{while(true){}})
- A function always throws (src_js{function foo(){throw new Error(‘Not Implemented’)}})
Syntax
let foo: never; // Okaylet foo: never = 123; // Error: Type number is not assignable to never
// Okay as the function's return type is `never`
let bar: never = (() => { throw new Error(`Throw my hands in the air like I just don't care`) })();