TypeScript
TypeScript Type InferenceTypeScript Type Inference
TypeScript guesses the correct data type automatically.
Read Time
5 min readDifficulty
BeginnerLast Updated
Jun 15, 2026Version
v1.0.0Introduction
You don't always have to write out the data types manually. If you assign a value to a variable immediately, TypeScript acts like a detective and figures out the correct type behind the scenes.
Example
Example
Key Points
- "Inference" means guessing automatically.
- It saves time and keeps the code clean.
- It still locks the type permanently after guessing.
- You only explicitly write types when you don't assign an initial value.