TypeScript · Junior · Question 37 of 75

What does the return type void mean?

Explanation

void is used for functions without a return value. Caveat: the callback type () => void allows passing a function that returns something (the result is ignored) - that's why arr.forEach(x => list.push(x)) compiles. A function that never finishes has the type never.

Further reading

Problem with a question

TypeScript · Junior · question 37

Test yourself

Take the TypeScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz