The Primitive Type never

In this lesson, you will see the type never, which is used to indicate that something must never happen.

The type never means that nothing occurs. It is used when a type guard cannot occur or in a situation where an exception is always thrown. There is a difference between void and never. A function that has the explicit return type of never won’t allow your code to return undefined, which is different from a void function that allows code to return undefined.

Get hands-on with 1400+ tech skills courses.