What is the void type in TypeScript?

Answer

The void type represents the absence of a return value from a function. It is used as the return type annotation for functions that do not explicitly return a value (or return undefined): function logMessage(msg: string): void { console.log(msg); }. A void function can return undefined or simply have no return statement — both are valid. void vs undefined: void is a broader concept — it signals to callers "do not expect a useful return value." A variable typed as void can only hold undefined. void in callbacks: when a function type uses void as a return type, it means the callee's return value is intentionally ignored: type Listener = (event: Event) => void — the listener can return any value, but it will be discarded. This is different from explicitly annotating a function as returning undefined.