Setting strict
to false makes TypeScript behave in ways which are much less safe.
As an example, strict
includes a setting called strictNullChecks
. Setting strictNullChecks
to false
will allow you to assign null
to a variable that is supposed to be a string:
let name: string = null; // No error
With strict
enabled, TypeScript will, of course, catch this error.
Another example of a strict
setting is noImplicitAny
. Setting noImplicitAny
to false
will allow you to leave function parameters un-annotated:
function greet(name) {
console.log(`Hello, ${name}!`);
}
This can lead to a flood of any
types in your codebase - which as we know, leads to a loss of type safety.
In fact, I’ve written this entire book on the premise that you have strict
enabled in your codebase. It’s the baseline for all modern TypeScript apps.