Why should we use "never" when we can use void while throwing Error?

2 weeks ago 16
ARTICLE AD BOX

I'm learning TypeScript and I noticed that when a function always throws an error, we can define its return type as never:

function throwError(message: string): never { throw new Error(message); }

However, this also works:

function throwError(message: string): void { throw new Error(message); }

Since both implementations throw an error and never return normally, I'm confused about why never is recommended over void in such cases.

My understanding so far:

void means the function does not return a value never means the function never completes normally (e.g., throws or runs infinitely)

Questions

From a type system perspective, what practical difference does it make to use never instead of void?

Does using never improve type narrowing or control flow analysis?

Are there real-world scenarios where using void instead of never could cause subtle bugs?

Is this mainly about semantic correctness, or does it have deeper implications in large codebases?

I'm trying to understand this from a design and best-practice perspective rather than just "it works".

Read Entire Article