L'annotation sur une donnée du dehors est un vœu, pas une preuve.The annotation on outside data is a wish, not a proof.
Tout ce qui entre dans le programme — réseau, JSON.parse, localStorage, process.env, formulaires — arrive non typé. Mais les signatures le cachent : on écrit const config: Config = JSON.parse(raw), le compilateur sourit, et l'on croit tenir un Config. On ne tient rien. Le type s'est effacé bien avant que les octets n'arrivent (Vol 2), et l'annotation n'a fait que blanchir un any (Vol 4). Ce volume paie la dette des deux : il nomme la frontière, et le seul endroit où la donnée devient vraiment typée.Everything entering the program — network, JSON.parse, localStorage, process.env, forms — arrives untyped. But the signatures hide it: you write const config: Config = JSON.parse(raw), the compiler smiles, and you think you hold a Config. You hold nothing. The type erased long before the bytes arrived (Vol 2), and the annotation merely laundered an any (Vol 4). This volume pays both debts: it names the boundary, and the one place where data truly becomes typed.
interface Config { port: number; host: string } const config: Config = JSON.parse(raw); // ✗ annoté Config — mais RIEN ne l'a vérifié config.port.toFixed(); // 💥 si le JSON n'a pas 'port' : crash, loin d'ici // JSON.parse renvoie 'any' : l'annotation est un vœu, pas une preuve (Vol 2 + Vol 4)
Annoter, ce n'est pas vérifier. : Config sur un JSON.parse décrète un type que personne n'a constaté — la donnée ne devient un fait qu'au moment d'un contrôle à l'exécution, jamais avant.Annotating isn't checking. : Config on a JSON.parse decrees a type no one observed — the data becomes a fact only at a runtime check, never before.
const data: unknown = JSON.parse(raw); // la vérité : on ne SAIT pas ce que c'est // impossible de toucher data.port sans prouver d'abord (Vol 4.2) : if (isConfig(data)) data.port.toFixed(); // ✓ typé seulement APRÈS la preuve // (le validateur en un geste, c'est le 7.2 — ici, on cesse de se mentir)
« Cette donnée vient-elle de l'extérieur — et si oui, à quel point précis devient-elle typée, et qui l'a prouvé ? » Si la réponse est « une annotation » ou « un as », elle n'est pas typée : elle est supposée."Does this data come from outside — and if so, at what exact point does it become typed, and who proved it?" If the answer is "an annotation" or "an as", it isn't typed: it's assumed.
Ce volume règle la dette laissée par le Vol 2 (le type s'efface) et le Vol 4 (any/as blanchissent). Ce premier numéro est un diagnostic : il montre d'où viennent les bugs runtime — la frontière qui ment. Le suivant prescrit le remède : valider une seule fois, au bord, et n'avoir plus que du typé sûr à l'intérieur.This volume settles the debt left by Vol 2 (the type erases) and Vol 4 (any/as launder). This first issue is a diagnosis: it shows where runtime bugs come from — the lying boundary. The next prescribes the cure: validate once, at the edge, and have only safe-typed data inside.