Un atelier TypeScript · Édition d'ApprentissageA TypeScript Workshop · Learning Edition

Le narrowing, ou la preuve qui se construit branche par branche Narrowing, or the proof built branch by branch

Un x: string | number | null ne se caste pas — il se prouve. À chaque if, chaque typeof, chaque return anticipé, TypeScript rétrécit le type : l'union perd un membre, branche par branche, jusqu'à ce qu'il sache exactement ce qu'on tient. C'est la façon de reconstruire une preuve par-dessus des valeurs nues. An x: string | number | null isn't cast — it's proven. At each if, each typeof, each early return, TypeScript narrows the type: the union loses a member, branch by branch, until it knows exactly what you hold. It's how a proof is rebuilt on top of bare values.

AudienceAudience
Dev qui a compris l'effacement et veut décider sûrement à l'exécution Dev who grasped erasure and wants to decide safely at runtime
Format
Self-paced
ChapitresChapters
5
Date
Juin 2026 Jun 2026
≈ 18 min ●●○○ NarrowingControl flowTradeoff
🔒

La suite est réservée The rest is members-only

Le premier numéro est libre. Débloque tout The TypeScript Loop — tous les volumes, à vie — pour 5 €, paiement unique. The first issue is free. Unlock all of The TypeScript Loop — every volume, forever — for €5, one-time.

Retour au kiosqueBack to newsstand