js-util

Home > rc-js-util > _Production > assertValueIsNever

_Production.assertValueIsNever() method

A function that will error if ever called. The parameter is asserted to be never, useful with switch statements, union types etc.

Signature:

static assertValueIsNever(_value: never): never;

Parameters

Parameter Type Description
_value never  

Returns:

never

Example

// adding extra values to the enum will cause a compiler error
enum ETest { Foo = 1 };
function test(value: ETest)
{
     switch (value) {
         case ETest.Foo: return "potato";
         default: return _Production.assertValueIsNever(value);
     }
}