0Pricing
TypeScript Academy · Lesson

Structural typing & excess property checks

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

Structural typing & excess property checks is a free TypeScript Academy lesson on CoddyKit — lesson 3 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the TypeScript Academy learning path, one of 3 lessons in the course, and your progress syncs across the web and the CoddyKit app.

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

Named vs structural

Unlike nominal systems, Point2D and Coord are compatible because they share the same structure.

type Point2D = { x: number; y: number };
type Coord = { x: number; y: number };

const p: Point2D = { x: 1, y: 2 };
const q: Coord = p; // OK, same structure

Excess check fail

Excess property checks apply to object literals assigned directly. Extra properties not in the target type cause errors.

interface User { id: number; name: string }

const u: User = { id: 1, name: "Ada", age: 30 }; // Error: excess property "age"

Bypass check

Assigning via a variable bypasses excess property checks. This allows flexibility, but be cautious about unintended props.

const raw = { id: 1, name: "Ada", age: 30 };
const u: User = raw; // OK, because variable assignment skips excess check

Guidelines

Guidelines:

  • Structural typing makes TS flexible.
  • Excess checks catch mistakes early.
  • Use variables when extra fields are intentional.

Structural typing check

Quick check: Which statement about structural typing is TRUE?

Recap

Recap: TypeScript uses structural typing: types match by members. Excess property checks protect object literals. Remember how to bypass them carefully.

Frequently asked questions

Is the “Structural typing & excess property checks” lesson free?

Yes — the full text of “Structural typing & excess property checks” is free to read here on the web, and the TypeScript Academy course includes 3 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the TypeScript Academy course, upgrade to CoddyKit PRO.

What will I learn in “Structural typing & excess property checks”?

Understand structural typing in TypeScript and how excess property checks prevent unintended object shapes. You practise TypeScript Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start TypeScript Academy?

No prior experience is required. TypeScript Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 3, so you can start here or from the beginning and move at your own pace.

How long does the “Structural typing & excess property checks” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this TypeScript Academy lesson?

Yes. Every TypeScript Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

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