Course contentsShow
← TypeScript
Lesson 440 of 1,79610. Intersection TypesFree lesson

Primitive Type Intersections

Why intersecting primitive types like string & number produces never and when this occurs.

Primitive Type Intersections

What you'll learn: Why trying to combine primitive types like string & number results in the impossible never type.


The Impossible Intersection

When you intersect two primitive types like string & number, TypeScript produces the never type. This makes sense when you think about what an intersection means: a value that is both types simultaneously.

A value cannot be both a string and a number at the same time. It's logically impossible. TypeScript recognizes this impossibility and represents it with never.

Why This Happens

Remember that intersection types (&) mean "this AND that." For object types, you can combine properties from multiple shapes. But primitives are indivisible atoms of data—they don't have properties to merge.

Think of it like asking for a color that is both red AND blue (not purple, but literally both red and blue at once). It can't exist.

type Impossible = string & number;  // never

const value: Impossible = "hello";  // Error: Type 'string' is not assignable to type 'never'
const value2: Impossible = 42;      // Error: Type 'number' is not assignable to type 'never'

When This Occurs

You'll typically encounter primitive intersections by accident:

  • Overly complex type manipulations
  • Conflicting constraints in generic functions
  • Incorrectly combined utility types

These situations usually indicate a logical error in your type design that needs correction.

Key Takeaway: Intersecting primitive types like string & number produces never because no value can be two different primitives simultaneously—it's a logical impossibility that TypeScript correctly represents.