Assignability Rules for never
What you'll learn: How never behaves uniquely in TypeScript's type system — it can be assigned anywhere, but nothing can be assigned to it.
The Two-Way Rule
The never type has a special asymmetric relationship with all other types in TypeScript's type system. Think of never as a universal donor but an absolute rejector:
nevercan be assigned to everything — You can use anevervalue anywhere any other type is expected- Only
nevercan be assigned tonever— Nothing else is compatible with anevertype
Why This Makes Sense
Remember that never represents values that can't exist. If something truly never happens, it's safe to use in any context because... it will never actually run. It's like saying "if pigs fly, they can go anywhere" — since pigs don't fly, the statement is vacuously true.
Conversely, if you have a variable explicitly typed as never, TypeScript enforces that absolutely nothing can be assigned to it (except another never), because never means "this cannot hold a value."
Practical Examples
never Goes Anywhere
let neverValue: never;
let str: string;
let num: number;
// These assignments compile (though you can't actually create neverValue)
str = neverValue; // ✓ OK
num = neverValue; // ✓ OK
Nothing Goes to never
let neverVar: never;
neverVar = "hello"; // ✗ Error: Type 'string' is not assignable to 'never'
neverVar = 42; // ✗ Error: Type 'number' is not assignable to 'never'
neverVar = undefined; // ✗ Error: Type 'undefined' is not assignable to 'never'
This is why never is called the bottom type — it's at the bottom of TypeScript's type hierarchy, assignable upward to everything but accepting nothing downward.
Key Takeaway: never is assignable to all types (universal donor), but only never is assignable to never (absolute rejector). This reflects its role as the type of values that cannot exist.