What does "strict typing" mean?
Strict typing means a language does not allow implicit (automatic) conversion of a value from one type to another if that could lead to unexpected behavior.
Simply put, TypeScript requires you to explicitly respect types and not mix, for example, string and number without an explicit conversion.
1. Example of "loose" typing (JavaScript)
JavaScript is a dynamically and weakly typed language, so it will try on its own to convert types to the needed form:
console.log("5" - 1); // 4 ← the string "5" is implicitly converted to a number
console.log("5" + 1); // "51" ← here, conversely, a number became a string
console.log(true + 1); // 2This behavior often causes unpredictable errors.
2. Example of strict typing (TypeScript)
TypeScript is a strictly typed language. It does not allow "mixing" types without your permission:
let count: number = 5;
count = "5"; // Error: type string is not assignable to type number
console.log("5" - 1); // Error at compile timeIf you still need to convert a type, do it explicitly:
let num = Number("5"); // Explicit conversion of a string to a number
console.log(num - 1); // 43. Difference between "strict" and "weak" typing
| Property | Strict typing | Weak typing |
|---|---|---|
| Type conversion | Only explicit | Often implicit |
| Compatibility check | At compile time | At runtime |
| Example languages | TypeScript, Java, C#, Rust | JavaScript, PHP, Python |
| Behavior for "5" + 1 | Error | "51" |
| Behavior for "5" - 1 | Error | 4 |
4. Why it matters
Strict typing helps:
- prevent hidden bugs and errors;
- make code predictable and safe;
- improve long-term maintainability and project scaling;
- get accurate IDE hints and autocomplete.
Summary
Strict typing is a principle by which a language strictly controls type compatibility and does not perform implicit conversions, so the programmer always consciously manages data types.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.