Why is 'never' the correct type for an empty array literal used as a union's building block, and how does it behave as a 'bottom type'?
Short answer
'never' is TypeScript's bottom type — a subtype of EVERY other type, but no type (except never itself) is a subtype of it.
Advertisement
AModel answer
'never' is TypeScript's bottom type — a subtype of EVERY other type, but no type (except never itself) is a subtype of it. This means never is compatible everywhere it's expected, and in a union type, `T | never` simplifies to just `T`, since never contributes no actual possible values — this is exactly why filtering unions down to nothing via conditional types (like Exclude) naturally lands on never.
type A = string | never; // simplifies to just 'string'
type B = never | number | never; // simplifies to just 'number'Real-world example
Understanding why Exclude<T,U> and other conditional-type utilities rely on never as their 'this branch produces nothing' signal.
Likely follow-ups
- Why can you assign a 'never' value to a variable of ANY other type, but not the reverse?
Related topics