function neverReturns(): never {
        throw new Error('An error!');
      }
      
      Typescript language logo

      Never function

      Codiga's TypeScript Recipes

      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.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.