2 ms·
This `never` type is the opposite of a null value, though. The "billion dollar mistake" (which is really the absence of non-nullable references, not merely the
by nybble41 5y ago
This `never` type is the opposite of a null value, though. The "billion dollar mistake" (which is really the absence of non-nullable references, not merely the presence of null or undefined) adds a possible value to every reference. At any point you could have a valid reference, or a null reference, and this makes it impossible to express the type of a reference which must be valid. The `never` type by contrast has no possible values. It offers a way to statically assert that nothing has been left unhandled.
A type system without `never` (or equivalent) is like a number system without zero. (Literally—`never` is the zero for algebraic data types.)