Never Type
Question
What is the never type?
Hint
never is the bottom type; every type is assignable to it.
Explanation
The never type represents values that never occur — the bottom of the type hierarchy. No value has type never. Uses: 1) Functions that never return (infinite loops, always throw). 2) Exhaustiveness checking: in a switch, the default case can assert never to ensure all cases are handled. 3) Conditional types that filter out impossible cases. 4) Error handling: function throwError(msg: string): never { throw new Error(msg); }. never is assignable to every type, but no type (except never itself) is assignable to never.
Related Resources
Related Lessons
- Basic Types
Learn basic types.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.