Skip to main content

require-strict-mode

Require "strict": true in compilerOptions to enable TypeScript's full set of type-safety checks.

Targeted pattern scopeโ€‹

The compilerOptions.strict field in any tsconfig*.json file.

What this rule reportsโ€‹

This rule reports when compilerOptions is present and compilerOptions.strict is absent or set to false. The rule does not report if compilerOptions is not defined at all, since there is no compiler configuration to check.

Why this rule existsโ€‹

strict: true is a composite flag that enables a suite of checks designed to catch the most common classes of type-unsafe code:

  • strictNullChecks โ€” prevents undefined/null from being assigned to non-nullable types.
  • strictFunctionTypes โ€” enforces contravariant function parameter types.
  • strictBindCallApply โ€” checks bind, call, and apply argument types.
  • strictPropertyInitialization โ€” ensures class properties are initialized.
  • noImplicitAny โ€” disallows implicit any on parameters and variables.
  • noImplicitThis โ€” disallows this expressions with an implied any type.
  • alwaysStrict โ€” emits "use strict" in output files.
  • useUnknownInCatchVariables โ€” types catch clause variables as unknown.

Omitting strict: true leaves these checks disabled, allowing entire categories of runtime errors to compile without warning.

The auto-fixer adds "strict": true to compilerOptions.

โŒ Incorrectโ€‹

{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext"
}
}

None of the strict checks are active.

{
"compilerOptions": {
"strict": false
}
}

Strict mode is explicitly disabled.

โœ… Correctโ€‹

{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"strict": true
}
}

When not to use itโ€‹

Disable this rule for tsconfig files used exclusively to configure type- checking tools or test runners that operate on already-compiled code, or for configurations that extend a strict base tsconfig and therefore inherit the strict setting from the parent.

Package documentationโ€‹

Rule catalog ID: R024

Further readingโ€‹