Void
What
The void type is a special TypeScript type that represents the return value of a function that does not return anything.
How
You use : void as the return type for functions that perform an action (like logging or updating a database) but don’t produce a value for the caller:
function logMessage(message: string): void {
console.log(message);
}
Why
In JavaScript, functions that don’t return a value actually return undefined. Using void explicitly communicates the intent that the function’s output should not be used, making your code’s behavior more predictable and easier to understand.
Summary
Use void to clearly mark functions that are “side-effect” only and do not have a meaningful return value.