0Pricing
TypeScript Academy · Lesson

Structural typing & excess property checks

Understand structural typing in TypeScript and how excess property checks prevent unintended object shapes.

Intro

Goal: Learn structural typing, where compatibility depends on having the right members, and how excess property checks work with object literals.

Structural typing

Structural typing: compatibility is by shape. If an object has at least the required properties, it is accepted, even if extra ones exist.

interface Point { x: number; y: number; }

function logPoint(p: Point) {
  console.log(p.x, p.y);
}

const a = { x: 5, y: 7, z: 99 };
logPoint(a); // OK because it has x and y

All lessons in this course

  1. Object types, optional/readonly, index signatures
  2. Interfaces vs Type Aliases
  3. Structural typing & excess property checks
← Back to TypeScript Academy