{"id":15001,"library":"typescript-strict-plugin","title":"TypeScript Strict Mode Plugin","description":"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.","status":"active","version":"2.4.4","language":"javascript","source_language":"en","source_url":"https://github.com/allegro/typescript-strict-plugin","tags":["javascript","TypeScript Strict","TypeScript plugin","TypeScript Language Service"],"install":[{"cmd":"npm install typescript-strict-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add typescript-strict-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add typescript-strict-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is a TypeScript Language Service Plugin and is configured directly in your `tsconfig.json`'s `compilerOptions.plugins` array, not imported as a JavaScript module.","wrong":"{ \"plugin\": \"typescript-strict-plugin\" }","symbol":"typescript-strict-plugin (in tsconfig.json)","correct":"{ \"name\": \"typescript-strict-plugin\" }"},{"note":"This is a CLI utility included with the package. It should be executed via `npx` or referenced from `./node_modules/.bin/` to ensure the correct executable is found. It helps migrate projects to v2 by adding `//@ts-strict-ignore` comments.","wrong":"node update-strict-comments","symbol":"update-strict-comments","correct":"npx update-strict-comments"},{"note":"This is a CLI utility for compile-time strictness checks. It's best used as part of a `package.json` script, e.g., `\"typecheck\": \"tsc && tsc-strict\"`, to ensure it runs in the correct environment and path. Direct execution might fail if not in the system's PATH.","wrong":"tsc-strict","symbol":"tsc-strict","correct":"npm run typecheck"}],"quickstart":{"code":"{\n  \"name\": \"my-strict-project\",\n  \"version\": \"1.0.0\",\n  \"devDependencies\": {\n    \"typescript\": \"^5.0.0\",\n    \"typescript-strict-plugin\": \"^2.0.0\"\n  },\n  \"scripts\": {\n    \"typecheck\": \"tsc --noEmit && tsc-strict\"\n  }\n}\n\n// tsconfig.json\n{\n  \"compilerOptions\": {\n    \"target\": \"ES2020\",\n    \"module\": \"CommonJS\",\n    \"strict\": false, // Crucial: Set to false for the plugin to manage strictness\n    \"esModuleInterop\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"skipLibCheck\": true,\n    \"plugins\": [\n      {\n        \"name\": \"typescript-strict-plugin\",\n        \"paths\": [\"./src\"], // Optionally specify paths to make strict by default\n        \"excludePattern\": [\"**/*.spec.ts\"]\n      }\n    ]\n  },\n  \"include\": [\"src/**/*.ts\"]\n}\n\n// 1. Install dependencies\n// npm install --save-dev typescript typescript-strict-plugin\n\n// 2. Run the migration script to ignore files with existing errors\n// npx update-strict-comments\n\n// 3. To run compile-time strict checks\n// npm run typecheck","lang":"typescript","description":"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."},"warnings":[{"fix":"Run `npx update-strict-comments` to automatically add `//@ts-strict-ignore` to files with strict errors, ensuring a smooth transition from v1 to v2.","message":"Version 2.0 introduced a breaking change by inverting the default strictness behavior. Previously, files were non-strict by default and opted-in with `//@ts-strict`. Now, files are strict by default and opt-out using `//@ts-strict-ignore`.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Add `tsc-strict` to your `package.json` scripts (e.g., `\"typecheck\": \"tsc --noEmit && tsc-strict\"`) and run it as part of your build pipeline.","message":"TypeScript Language Service Plugins (like this one) primarily affect IDE feedback. To enforce strict checks at compile-time during your build process, you *must* use the `tsc-strict` CLI utility provided by the package.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure `\"strict\": false` is explicitly set in your `tsconfig.json` under `compilerOptions`.","message":"For the plugin to manage partial strictness (i.e., making some files strict while others are not), your `tsconfig.json`'s `compilerOptions.strict` flag must be set to `false`. If `strict` is `true`, the plugin's effect will be overridden by the global compiler setting.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Be mindful when passing arguments to `tsc-strict`. Only override specific options when you intend to temporarily deviate from your `tsconfig.json` settings.","message":"Command-line arguments passed to `tsc-strict` (e.g., `--strictNullChecks false`) will override the compiler options configured in your `tsconfig.json` for the strict checks performed by `tsc-strict`. This can lead to unexpected behavior if not understood.","severity":"gotcha","affected_versions":">=1.1.2"},{"fix":"Ensure `//@ts-strict-ignore` is the first meaningful line of code or comment in the file you wish to ignore.","message":"The `//@ts-strict-ignore` comment must be placed at the very top of a TypeScript file to be effective in disabling strict checks for that file. If it's not the first line (after any shebang or license comments), it may not be parsed correctly by the plugin.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev typescript-strict-plugin` and verify that `\"name\": \"typescript-strict-plugin\"` is correctly configured in your `tsconfig.json` under `compilerOptions.plugins`.","cause":"The plugin is not installed as a `devDependency` or its name is misspelled in `tsconfig.json`.","error":"Error: Plugin 'typescript-strict-plugin' not found. Make sure it's installed and listed in your tsconfig.json."},{"fix":"Execute `tsc-strict` using `npx tsc-strict` or by defining a script in your `package.json` (e.g., `\"scripts\": { \"strict-check\": \"tsc-strict\" }`) and running `npm run strict-check`.","cause":"The `tsc-strict` executable is not in your system's PATH when you try to run it directly.","error":"tsc-strict: command not found"},{"fix":"You need to integrate the `tsc-strict` CLI tool into your build process. Add it to a `package.json` script, for example: `\"scripts\": { \"build\": \"tsc --noEmit && tsc-strict\" }`.","cause":"The plugin's primary function is for IDE feedback. The default `tsc` command does not run the plugin's strictness checks.","error":"Strict errors are not appearing in my terminal when I run `tsc`."},{"fix":"Ensure `//@ts-strict-ignore` is the very first line of your file. Also, confirm that `\"strict\": false` is set in your `compilerOptions` within `tsconfig.json` for the plugin to take effect.","cause":"The `//@ts-strict-ignore` comment might not be at the absolute top of the file, or your `tsconfig.json` has `\"strict\": true`, overriding the plugin.","error":"My files are still showing strict errors even with `//@ts-strict-ignore` at the top."}],"ecosystem":"npm"}