Suggest an editImprove this articleRefine the answer for “Intersection of primitives”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)If you intersect **incompatible types**, for example `type Impossible = string & number`, the result is the type **`never`**. **Key point:** the `&` (intersection) operator means "both at the same time", and since a value cannot be a string and a number simultaneously, the intersection is empty, so TypeScript infers `never` - a type with no possible values.Shown above the full answer for quick recall.Answer (EN)Image## Short answer If you combine **incompatible types**, for example: ```javascript type Impossible = string & number; ``` The result is the type `never`. --- ## Why this happens The `&` (intersection) operator means **"both at the same time"**. TypeScript tries to build a type that **matches all the combined types at once**. - `string` means "any string" - `number` means "any number" But a value **cannot be a string and a number at the same time**, so the **intersection is empty**, and TypeScript infers the type `never`. --- ## Example 1. A direct intersection of incompatible types ```javascript type A = string & number; // => never let x: A; // x = "text"; error // x = 123; error // x = null; error ``` > The type `A` equals `never`, meaning the value is **impossible**. > TypeScript will not let you assign **anything**. --- ## Example 2. An intersection of partially compatible types Sometimes part of the properties overlaps, and TypeScript keeps only the **shared** fields. ```javascript type A = { id: number; name: string }; type B = { id: number; age: number }; type C = A & B; /* C = { id: number; // shared field name: string; // from A age: number; // from B } */ const person: C = { id: 1, name: "Tim", age: 25 }; // OK ``` > Everything is compatible here, TypeScript just merged the properties. --- ## Example 3. An intersection with conflicting property types ```javascript type A = { id: number }; type B = { id: string }; type C = A & B; // id must be both number and string -> incompatible ``` Now `C["id"]` = `number & string` -> `never`. Therefore the whole type is: ```javascript type C = { id: never }; ``` It is impossible to create a valid value: ```javascript const obj: C = { id: 123 }; // error const obj2: C = { id: "123" }; // error ``` --- ## Example 4. An intersection of union types ```javascript type A = string | number; type B = number | boolean; type C = A & B; // => number ``` Here TypeScript computes the **common part of the two sets**: - A = { string, number } - B = { number, boolean } - Intersection = { number } --- ## Logical comparison | Operation type | Symbol | Logic | |---|---|---| | ` | ` (union) | OR | | `&` (intersection) | AND | Takes only what fits everything at once | --- ## Summary | Expression | Result | Explanation | |---|---|---| | `string & number` | `never` | incompatible types | | `{ id: number } & { id: string }` | `{ id: never }` | conflict on a field | | `{ name: string } & { age: number }` | `{ name: string; age: number }` | compatible | | `(string | number) & (number | boolean)` | --- ### In short: > If you combine types that **cannot exist at the same time**, > TypeScript infers `never` - a type with **no possible values**.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.