TypeScript Strict Mode Plugin

2.4.4 · active · verified Sun Apr 19

The `typescript-strict-plugin` enables gradual adoption of TypeScript's strict mode in existing large projects. Instead of refactoring an entire codebase at once, developers can configure this plugin to apply strict type checking to specific files or directories, or enable strict mode by default and opt out problematic files. The current stable version is 2.4.4. It offers a clear migration path with its `update-strict-comments` script, which automatically adds `//@ts-strict-ignore` comments to files containing strict errors. This allows new or refactored code to benefit from strict checks immediately, while legacy code can be addressed incrementally. It also provides a CLI tool, `tsc-strict`, to ensure compile-time strictness checks, as TypeScript language service plugins typically only affect IDE feedback. The project appears to have an active release cadence, with recent updates addressing bug fixes and compatibility. Its key differentiator is providing a flexible, file-level control over strict mode, effectively solving the "all-or-nothing" barrier for large-scale migrations.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to install `typescript-strict-plugin`, configure it in `tsconfig.json` to enable partial strictness, run the `update-strict-comments` migration script, and integrate `tsc-strict` into your `package.json` scripts for compile-time checking.

{
  "name": "my-strict-project",
  "version": "1.0.0",
  "devDependencies": {
    "typescript": "^5.0.0",
    "typescript-strict-plugin": "^2.0.0"
  },
  "scripts": {
    "typecheck": "tsc --noEmit && tsc-strict"
  }
}

// tsconfig.json
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "CommonJS",
    "strict": false, // Crucial: Set to false for the plugin to manage strictness
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "skipLibCheck": true,
    "plugins": [
      {
        "name": "typescript-strict-plugin",
        "paths": ["./src"], // Optionally specify paths to make strict by default
        "excludePattern": ["**/*.spec.ts"]
      }
    ]
  },
  "include": ["src/**/*.ts"]
}

// 1. Install dependencies
// npm install --save-dev typescript typescript-strict-plugin

// 2. Run the migration script to ignore files with existing errors
// npx update-strict-comments

// 3. To run compile-time strict checks
// npm run typecheck

view raw JSON →