Advertisement
Beginner Angular, TypeScript with Angular

What does strict mode in Angular's TypeScript configuration do, and why is it recommended?

Short answer

Strict mode enables a stricter set of TypeScript checks, such as disallowing implicit any types and requiring null checks before using a potentially null value, catching more potential bugs at compile time rather than letting them surface later as runtime errors in production.

Save Angular mock interview
Advertisement
AModel answer
Strict mode enables a stricter set of TypeScript checks, such as disallowing implicit any types and requiring null checks before using a potentially null value, catching more potential bugs at compile time rather than letting them surface later as runtime errors in production.
// tsconfig.json
{
  "compilerOptions": {
    "strict": true
  }
}
Real-world example
A team enables strict mode on a new Angular project from the very beginning, catching several potential null reference errors during development that would have otherwise only appeared as confusing runtime crashes for real users later.
Likely follow-ups
  • What specific individual checks does enabling strict mode actually turn on?
  • Is it difficult to enable strict mode on an existing, older project that was not built with it from the start?
Related topics