Visit complete TypeScript roadmap

← Back to Topics List


The never type represents the type of values that never occur. For instance, never is the return type for a function expression or an arrow function expression that always throws an exception or one that never returns. Variables also acquire the type never when narrowed by any type guards that can never be true.

The never type is a subtype of, and assignable to, every type; however, no type is a subtype of, or assignable to, never (except never itself). Even any isn’t assignable to never.

Examples of functions returning never:

// Function returning never must not have a reachable end point
function error(message: string): never {
  throw new Error(message);

// Inferred return type is never
function fail() {
  return error('Something failed');

// Function returning never must not have a reachable end point
function infiniteLoop(): never {
  while (true) {}

Learn more from the following links:

Community is the 6th most starred project on GitHub and is visited by hundreds of thousands of developers every month.

Roadmaps Best Practices Guides Videos Store YouTube by Kamran Ahmed

Community created roadmaps, articles, resources and journeys to help you choose your path and grow in your career.

© · FAQs · Terms · Privacy


The leading DevOps resource for Kubernetes, cloud-native computing, and the latest in at-scale development, deployment, and management.