void (TypeScript)
`void` is the return type for a function that doesn't return a useful value. It signals that the function runs for its side effects, like logging or updating state, rather than producing a result.
TypeScript
Whereas `never` means a function never returns at all, `void` means it returns but you should ignore whatever it gives back (in practice, `undefined`).
You'll see `void` most often on functions like event handlers and `console.log`-style helpers, and as the type of callbacks whose result is not used.
Examples
TypeScript
function logMessage(msg: string): void {
console.log(msg);
}
logMessage("saved");Output:
saved