From book Basarat - TypeScript Deep Dive
interface Point2D {
x: number;
y: number;
}
interface Point3D {
x: number;
y: number;
z: number;
}
var point2D: Point2D = { x: 0, y: 10 }
var point3D: Point3D = { x: 0, y: 10, z: 20 }
function iTakePoint2D(point: Point2D) { /* do something */ }
iTakePoint2D(point2D); // exact match okay
iTakePoint2D(point3D); // extra information okay
iTakePoint2D({ x: 0 }); // Error: missing information `y`
I replace this line:
iTakePoint2D(point3D); // extra information okay
with
iTakePoint2D({ x: 0, y: 10, z: 20 });
and I have an Error. Why is now extra information not okay?