Concept: Type Widening
Concept Check Medium
Question
What is type widening in TypeScript?
Hint
Think about let vs const — why does let x = 5 give number but const x = 5 gives 5?
Explanation
Type widening occurs when TypeScript generalizes a literal type to its base type. For let x = 5, x is widened to number because let variables can be reassigned. For const x = 5, x stays as the literal type 5 because const cannot change. You can prevent widening with as const.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.