Void Type
In one line
The void type indicates that a function's return value should not be used. It is the return type for functions that don't return anything meaningful.
In simple words
The void type means "the return value of this function should be ignored." It is used for functions that perform an action but don't produce a result, like event handlers and logging functions.
void differs from undefined: a void function can return anything (the value is just ignored), while an undefined function must specifically return undefined. This matters for callbacks — a void-returning callback can return any type.
You rarely write void yourself — it is usually inferred for functions without a return statement. It is most useful for typing callback parameters where the return value is ignored.
Example
function logMessage(msg: string): void {
console.log(msg);
// no return statement
}
// Callback with void return type
function forEach<T>(arr: T[], cb: (x: T) => void): void {
arr.forEach(cb);
}void means the return value is ignored. Callbacks with void can return anything.
Related terms
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.