What is the void type in TypeScript?

Why Interviewers Ask This

This is a classic screening question for TypeScript roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.

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.

Pro Tip

If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.