Never Type
In one line
The never type represents a value that never occurs — no value can have type never. It is used for functions that always throw and for exhaustiveness checking.
In simple words
The never type means "this can never happen." No value can have type never. It is used for functions that always throw an error or have infinite loops (they never return), and for exhaustiveness checking.
In exhaustiveness checking, if you handle all cases of a union in a switch, the default branch has type never. If you later add a new case to the union, the default branch is no longer never, and TypeScript errors — forcing you to handle the new case.
never is the bottom type: it is assignable to every type, but no type is assignable to it (except never itself). It is also the result of impossible intersections like string & number.
Example
function throwError(msg: string): never {
throw new Error(msg); // never returns
}
// Exhaustiveness checking
type Shape = "circle" | "square";
function area(s: Shape): number {
switch (s) {
case "circle": return Math.PI;
case "square": return 1;
default: const _exhaustive: never = s; return _exhaustive;
}
}throwError returns never. The default case uses never for exhaustiveness checking.
Related terms
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.