strict: false
What strict: true does
When tsconfig.json has:
{
"compilerOptions": {
"strict": true
}
}- TypeScript turns on the entire set of strict checks that make it an actually safe language, not just type highlighting.
"strict": true is a combo flag that immediately turns on all the strict checks at once (the equivalent of a whole set of options):
{
"strict": true
}≡ turns on:
noImplicitAnystrictNullChecksstrictBindCallApplystrictFunctionTypesstrictPropertyInitializationnoImplicitThisalwaysStrict
Why TypeScript without strict is almost pointless
Because the entire point of TypeScript is to guarantee type safety. If strict is off, TypeScript stops doing that.
It starts guessing about types, allows implicit any, and does not check the most common sources of bugs (for example, null, undefined, argument mismatches, and so on).
In other words:
Without strict, TypeScript ≈ JavaScript + types "for show".
1. Without noImplicitAny typing loses its point
function sum(a, b) {
return a + b;
}Without strict, TypeScript treats a and b as type any. You can call:
sum(2, "abc"); // OKTypeScript will not warn you, even though the result will be
"2abc".
With strict: true:
function sum(a: number, b: number): number {
return a + b;
}Now:
sum(2, "abc"); // Type error2. Without strictNullChecks you lose protection from null / undefined
function greet(name: string) {
console.log("Hi " + name.toUpperCase());
}
greet(undefined); // Runtime errorWithout strict, TypeScript thinks:
"well, what if
undefinedis fine here"
With strictNullChecks: true:
Error: Argument of type 'undefined' is not assignable to parameter of type 'string'.
This is the main reason strict is needed: 60-70% of real bugs in JS are related to
undefined.
3. Without strictPropertyInitialization classes become unsafe
class User {
name: string;
greet() {
console.log("Hi " + this.name.toUpperCase());
}
}
new User().greet(); // this.name = undefined → error at runtimeWith strict: true:
Error: Property 'name' has no initializer and is not definitely assigned.
Now you are required to initialize the property in the constructor:
class User {
name: string;
constructor(name: string) {
this.name = name;
}
}4. Without strictFunctionTypes you can break function compatibility
let fn: (a: string) => void;
fn = (a: any) => console.log(a); // This should be forbiddenWithout
strict, TS treats this as normal: you lose safety when passing callbacks.
5. Without noImplicitThis you can get strange context bugs
function sayHi() {
console.log(this.message);
}
sayHi.call({ message: "Hello" });
sayHi(); // this === undefinedWithout
strict, TypeScript will not check thatthisis undefined.
With strict you will get an error:
'this' implicitly has type 'any'.
6. Without alwaysStrict TS does not use JS strict mode
TypeScript stops compiling files with "use strict", which leads to more "relaxed" JavaScript behavior (for example, non-strict handling of this, delete, var, and so on).
7. Without strict, TS stops being a "safety net"
Without strict, TS cannot guarantee that the code is correct.
Example:
function processData(data) {
return data.value.toFixed(2);
}
processData(null); // Runtime errorTypeScript will not even tell you that data could be null. With strict, it will warn you right away:
Object is possibly 'null'.
8. The any type becomes a virus
When strict is off, TypeScript often automatically substitutes any whenever it does not know the type.
let user; // implicit any
user.toUpperCase(); // runtime error"undefined" types start spreading throughout the whole codebase.
With strict:
Error: Variable 'user' implicitly has an 'any' type.
9. When strict is on, the compiler helps you write reliable code
TypeScript starts to:
- check every nullable case (
null,undefined); - control property initialization in classes;
- forbid implicit
any; - make functions contravariant (that is, incompatible on dangerous arguments);
- help the IDE offer safe autocompletion.
Example: a project without strict vs with strict
| Scenario | Without strict | With strict: true |
|---|---|---|
| Unspecified types | implicit any | error |
null and undefined | pass without errors | error |
| Class properties without initialization | allowed | error |
Errors in the this context | not checked | checked |
| Type safety | minimal | high |
| IntelliSense | imprecise | precise |
| Runtime bugs | frequent | rare |
10. A simple analogy
Without
strict, TypeScript just adds syntax highlighting and autocompletion.With
strict: true, it becomes a genuine static analyzer that actually protects your code from 90% of typical JS bugs.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.