assertNever CallableassertNever<V>(subject): VRaise a compile error when accessing this function and throws a TypeError at runtime This is useful for exhaustive switch check.@exampleconst print = (fruit: 'banana'|'kiwi') => { switch (fruit) { case 'banana': return '🍌 Banana'; case 'kiwi': return '🥝 Kiwi'; default: return assertNever(fruit); // <- This line will report an error if a case is missing }}
Raise a compile error when accessing this function and throws a TypeError at runtime This is useful for exhaustive switch check.