AI Hints
Home›TypeScript Tutorial›Combining Shapes
TypeScript · Lesson 26 of 120

Intersection Types

Combine shapes.

⏱ 2 min read▶ Video at 20:28🎓 Free
Watch this lesson in the TypeScript courseWatch on YouTube ↗Full TypeScript course

With type aliases, you combine shapes using an ampersand. The result has every property from both sides. That's an intersection type.

Intersection Types
From the video: Intersection Types
  • Ampersand
  • Both shapes
  • Intersection

Combining with &

Timestamps holds when something was created. A tracked order is an order and timestamps together. It must have every property from both. Run it.

app.tstypescript
type Order = { id: number; total: number };
type Timestamps = { createdAt: string };

type TrackedOrder = Order & Timestamps;

const order: TrackedOrder = { id: 1042, total: 65, createdAt: "2026-11-13" };
console.log(order);
Output
{ id: 1042, total: 65, createdAt: '2026-11-13' }

extends or &

Both combine shapes. Extends is for interfaces, and gives clearer error messages. Ampersand works with any type alias, even unions. Use whichever matches the style you chose.

keyvalue
extendsinterfaces
&type aliases
Errorsextends is clearer
Choosematch your style

Summary

An ampersand combines types, so the result has every property from both. Next, index signatures.

Key takeaways
  • A & B
  • Every property
  • Type aliases
Next up: Index Signatures — dictionaries