Course contentsShow
← TypeScript
Lesson 948 of 1,79622. The never TypeFree lesson

Assignability Rules for never

Understanding that never is assignable to everything, but nothing except never is assignable to never.

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:

  1. never can be assigned to everything — You can use a never value anywhere any other type is expected
  2. Only never can be assigned to never — Nothing else is compatible with a never type

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.