Skip to content

Structural Typing

Medium — good to knowGeneral Dev

ELI5 — The Vibe Check

Structural typing is TypeScript's dating philosophy: it doesn't care about your name, only your shape. If you have all the right properties, you're compatible — no formal introduction needed. If it walks like a duck and quacks like a duck, TypeScript says it's a duck.

Real Talk

A type system where type compatibility is determined by the structure (properties and methods) of types rather than their explicit declarations or names. TypeScript uses structural typing: if an object has all the required properties of a type, it's considered compatible regardless of where it was defined.

Show Me The Code

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

function plot(p: Point) { /* ... */ }

// Works! Same shape, no explicit 'implements'
const myObj = { x: 10, y: 20, z: 30 };
plot(myObj); // OK: has x and y

When You'll Hear This

"TypeScript uses structural typing, so you don't need 'implements' — just match the shape." / "Structural typing is why TypeScript feels flexible compared to Java's nominal system."

Made with passive-aggressive love by manoga.digital. Powered by Claude.