← Back to libraryQuestion 222 of 468
🔷TypeScriptIntermediate

tsconfig.json and strict Mode

📌 Definition:

tsconfig.json configures the TypeScript compiler — which files to include, the target JS version, module system, and type-checking strictness. Enabling strict is the key to real type safety.

📖 Detailed Explanation:

Important options: target (ES version to emit), module (CommonJS/ESNext), outDir/rootDir, esModuleInterop (smooth default imports), and include/exclude. The strict flag turns on a bundle of strict checks: strictNullChecks (null/undefined must be handled), noImplicitAny (no silent any), strictFunctionTypes, and more. Turning strict on for an automation project catches the most bugs; other useful flags are noUnusedLocals, noImplicitReturns, and skipLibCheck. Framework starters (Playwright, Cypress) ship a tsconfig you extend. Without strict, TypeScript's safety is significantly weaker.

🔑 Key Points:
  • tsconfig.json sets target, module, paths, include/exclude
  • strict enables strictNullChecks + noImplicitAny + more
  • strict is where most of TS's bug-catching value comes from
  • Extend framework-provided tsconfigs (Playwright/Cypress)
🌍 Real-World Example:

Turning on strict in a Cypress project surfaces dozens of places where a possibly-undefined element or response field was used unguarded — each a latent flaky-test cause now caught at compile time.

🎯 Scenario-Based Interview Question:

A team's TypeScript catches almost no bugs. You check tsconfig and strict is false. What do you enable and what's the main risk?