Structural Typing
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."
Related Terms
Duck Typing
Duck typing is the ultimate 'don't ask for a resume' approach. If it walks like a duck and quacks like a duck, it's a duck.
Interface
An interface is like a job description. It says 'whatever fills this role must be able to do X, Y, and Z' without caring how they do it.
Nominal Typing
Nominal typing is the VIP list at a club — even if you look exactly like someone on the list, you can't get in unless your name matches.
TypeScript
TypeScript is JavaScript with a strict parent watching over it.