Le structurel avalerait la faute de frappe. Un contrôle l'arrête.Structural typing would swallow the typo. One check stops it.
Vol 1.1 l'a posé : un objet avec des champs en trop passe, du moment qu'il a la bonne forme. Mais alors un isAdmin mal tapé — au lieu de admin — devrait passer aussi, et la propriété attendue resterait silencieusement vide. TypeScript fait ici une exception : sur un littéral écrit à l'endroit même, il refuse les champs inconnus.Vol 1.1 established it: an object with extra fields passes, as long as it has the right shape. But then a mistyped isAdmin — instead of admin — should pass too, and the expected property would stay silently empty. TypeScript makes an exception here: on a literal written at the very spot, it rejects unknown fields.
type Options = { name: string; admin?: boolean }; function createUser(o: Options) { /* ... */ } createUser({ name: "Ada", isAdmin: true }); // ^^^^^^^ // error: Object literal may only specify known properties, // but 'isAdmin' does not exist in type 'Options'. // Did you mean to write 'admin'?
Structurellement, l'objet est un Options valide : il a name, admin est optionnel. isAdmin serait juste du bruit en trop — et admin resterait undefined. Le contrôle de champs en trop est là pour ça.Structurally, the object is a valid Options: it has name, admin is optional. isAdmin would just be extra noise — and admin would stay undefined. The excess property check exists for exactly this.
« Ce contrôle qui refuse mes champs en trop — sur quoi porte-t-il exactement, et que ne protège-t-il pas ? » Ce n'est pas une garantie structurelle de plus : c'est un linter cousu dans le type, qui ne s'arme que dans un cas précis."This check that rejects my extra fields — what exactly does it cover, and what does it not protect?" It's not one more structural guarantee: it's a linter sewn into the type, armed only in one precise case.
Le volume a montré le structurel (la forme), puis la composition (unions, intersections). Il restait une exception à nommer — la seule entorse au structurel — sous peine de la subir comme une incohérence. Comprends la fraîcheur, et le compilateur cesse de souffler le chaud et le froid sur les mêmes objets.The volume showed structural typing (the shape), then composition (unions, intersections). One exception remained to name — the only break from structural typing — lest you suffer it as an inconsistency. Understand freshness, and the compiler stops blowing hot and cold on the same objects.