Open In App

What is the never type in TypeScript?

Last Updated : 23 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

In TypeScript, the never type is used to specify the types that do not occur. It is mostly used to represent the functions that do not return any type of value after execution of the code written inside it. It can also be used to define the terminating condition for an expression if it does not have a reachable endpoint. The never type can also be defined as a subtype of all other types available in TypeScript because you can assign the value of never type to any other type. But can not do the vice-versa.

Syntax:

function function_name(): never {
// Function Statements
}

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads