How to fix Strict mode is not enabled in TypeScript

TypeScriptBEGINNERLOWUpdated Dec 11, 2025ยท 111 views

This TypeScript configuration error occurs when the "strict" compiler option is not enabled in tsconfig.json. Strict mode provides stronger type checking and helps catch potential runtime errors during compilation. Enabling it improves code quality and prevents common type-related bugs.

Quick fix

Fixes Strict mode is not enabled

// tsconfig.json
{
  "compilerOptions": {
    // Look for the "strict" property
    "strict": true  // Should be true to enable strict mode
  }
}
  1. Check your current tsconfig.json configuration
  2. Enable strict mode in tsconfig.json
  3. Fix any new type errors that appear
  4. Enable individual strict options if needed
typescript โ€” error
// tsconfig.json
{
"compilerOptions": {
// Look for the "strict" property
"strict": true // Should be true to enable strict mode
}
}
Strict mode is not enabled

What this error means

The "Strict mode is not enabled" warning or error indicates that TypeScript's comprehensive strict type checking features are disabled in your project configuration. TypeScript's strict mode is actually a collection of several individual strict checking flags that work together to provide maximum type safety. When strict mode is not enabled, TypeScript uses more permissive type checking rules, which can lead to: - Implicit "any" types being allowed - Less strict null checking - Weaker function type checking - Potential runtime errors that could have been caught at compile time This is typically not an error that stops compilation, but rather a configuration warning that suggests enabling stricter type checking for better code quality and error prevention. Many development teams and projects require strict mode to be enabled to maintain high code quality standards.

Typical symptoms

  • TypeScript compiler warnings about "strict mode is not enabled"
  • Missing type errors that would be caught with stricter checking
  • Code compiles successfully but may have runtime type errors
  • IDE or editor shows fewer type warnings than expected
  • Project may not follow TypeScript best practices for type safety

Common causes

  1. The "strict" compiler option is set to false or omitted in tsconfig.json
  2. Migrating from JavaScript to TypeScript without updating configuration
  3. Using an outdated tsconfig.json template
  4. Disabling strict mode to quickly fix type errors during migration
  5. Project was created without strict mode enabled by default

How to fix "Strict mode is not enabled"

1Check your current tsconfig.json configuration

First, examine your tsconfig.json file to see if strict mode is enabled:

json
// tsconfig.json
{
  "compilerOptions": {
    // Look for the "strict" property
    "strict": true  // Should be true to enable strict mode
  }
}

If the "strict" property is missing or set to false, that's the cause of the warning.

2Enable strict mode in tsconfig.json

Update your tsconfig.json to enable strict mode:

json
{
  "compilerOptions": {
    "strict": true,
    // Other compiler options...
    "target": "es2020",
    "module": "commonjs",
    "outDir": "./dist"
  }
}

Setting "strict": true enables all strict type-checking options at once.

3Fix any new type errors that appear

After enabling strict mode, you may see new type errors. Common fixes include:

1. Add explicit type annotations for variables with implicit 'any' type:

typescript
// Before: implicit any
const myVar = getValue();

// After: explicit type
const myVar: string = getValue();

2. Handle null/undefined properly with strict null checks:

typescript
// Before: potential runtime error
const length = someString.length;

// After: null check
const length = someString?.length ?? 0;

3. Fix function type mismatches that strict mode catches.

4Enable individual strict options if needed

If enabling all strict checks at once causes too many errors, you can enable them individually:

json
{
  "compilerOptions": {
    "strict": false,  // Disable the umbrella flag
    // Enable specific strict checks
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictBindCallApply": true,
    "strictPropertyInitialization": true,
    "noImplicitThis": true,
    "alwaysStrict": true
  }
}

This lets you adopt strict mode gradually by fixing one category of errors at a time.

5Verify strict mode is working

Create a test file to verify strict mode is enabled:

typescript
// test-strict.ts
// This should cause an error with strict mode enabled
const implicitAny = (x) => x + 1;  // Error: Parameter 'x' implicitly has 'any' type

// This should also cause an error
let potentiallyNull: string | null = null;
const length = potentiallyNull.length;  // Error: Object is possibly 'null'

Run tsc --noEmit to check for type errors. If you see errors for these cases, strict mode is working.

6Update build and CI configurations

Ensure your build tools and CI/CD pipeline respect the tsconfig.json changes:

1. Update package.json scripts:

json
{
  "scripts": {
    "build": "tsc",
    "type-check": "tsc --noEmit"
  }
}

2. Update CI configuration (GitHub Actions, GitLab CI, etc.) to run type checking:

yaml
# GitHub Actions example
- name: Type check
  run: npm run type-check

3. Update IDE/editor settings to use the project's tsconfig.json.

Advanced notes

## Understanding TypeScript's Strict Mode Family

TypeScript's strict mode is actually a collection of individual compiler flags:

- noImplicitAny: Raises error on expressions and declarations with implied 'any' type
- strictNullChecks: Null and undefined are not in the domain of every type
- strictFunctionTypes: Disable bivariant parameter checking for function types
- strictBindCallApply: Enable stricter checking of bind, call, and apply methods
- strictPropertyInitialization: Ensure non-undefined class properties are initialized in constructor
- noImplicitThis: Raise error on 'this' expressions with implied 'any' type
- alwaysStrict: Parse in strict mode and emit "use strict" for each source file
- useUnknownInCatchVariables: Default catch clause variables as 'unknown' instead of 'any'

## Migration Strategies

When migrating a large codebase to strict mode:

1. Start with strictNullChecks - This catches the most common runtime errors
2. Then enable noImplicitAny - Forces explicit type annotations
3. Use // @ts-ignore comments temporarily for difficult-to-fix cases
4. Consider using TypeScript's "checkJs" for JavaScript files in the project
5. Set up incremental adoption with different tsconfig files for different parts of the codebase

## Performance Considerations

Strict mode does add some compilation overhead, but the benefits for catching bugs early far outweigh the minor performance cost. For very large codebases, consider using project references to split compilation.

Frequently asked questions

What does "Strict mode is not enabled" mean?
The "Strict mode is not enabled" warning or error indicates that TypeScript's comprehensive strict type checking features are disabled in your project configuration. TypeScript's strict mode is actually a collection of several individual strict checking flags that work together to provide maximum type safety. When strict mode is not enabled, TypeScript uses more permissive type checking rules, which can lead to: - Implicit "any" types being allowed - Less strict null checking - Weaker function type checking - Potential runtime errors that could have been caught at compile time This is typically not an error that stops compilation, but rather a configuration warning that suggests enabling stricter type checking for better code quality and error prevention.
How do I fix "Strict mode is not enabled"?
This TypeScript configuration error occurs when the "strict" compiler option is not enabled in tsconfig.json. Strict mode provides stronger type checking and helps catch potential runtime errors during compilation. Enabling it improves code quality and prevents common type-related bugs.
What causes "Strict mode is not enabled"?
The "strict" compiler option is set to false or omitted in tsconfig.json Migrating from JavaScript to TypeScript without updating configuration Using an outdated tsconfig.json template
Is the "Strict mode is not enabled" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading