Never type
The never
type represents values that never occur. It is used to denote functions or expressions that never return or throw an error.
For instance an infinite loop:
Throwing an error:
The never
type is useful in ensuring type safety and catching potential errors in your code. It helps TypeScript analyze and infer more precise types when used in combination with other types and control flow statements, for instance: