TypeScript · Junior · Question 4 of 75
What does the never type mean?
- ✓Correct answer: The type of a value that can't exist: the function never returns control
- 2The same as
void: the function returns nothing and finishes normally - 3The same as
null: the value is absent, but the variable exists
Explanation
never is the empty type. It's returned by functions that always throw or loop forever. It also appears when a union is fully narrowed - exhaustive switch checks are built on this. void means the function finishes but its result isn't used.