{"id":14156629,"url":"https://github.com/allegro/typescript-strict-plugin","last_synced_at":"2025-05-14T15:07:24.728Z","repository":{"id":39903687,"uuid":"349366967","full_name":"allegro/typescript-strict-plugin","owner":"allegro","description":"Typescript plugin that allows turning on strict mode in specific files or directories.","archived":false,"fork":false,"pushed_at":"2024-11-29T02:45:27.000Z","size":863,"stargazers_count":375,"open_issues_count":25,"forks_count":30,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-13T05:25:25.561Z","etag":null,"topics":["strict-mode","ts-strict","typescript","typescript-compiler","typescript-library","typescript-plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/allegro.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-19T09:25:44.000Z","updated_at":"2025-05-07T14:51:21.000Z","dependencies_parsed_at":"2024-04-10T06:38:10.999Z","dependency_job_id":"c88444f8-7896-4389-b9b2-12280712b263","html_url":"https://github.com/allegro/typescript-strict-plugin","commit_stats":{"total_commits":71,"total_committers":13,"mean_commits":5.461538461538462,"dds":"0.43661971830985913","last_synced_commit":"3542842f9b324e7f116170bbc5b15935cba9defb"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allegro%2Ftypescript-strict-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allegro%2Ftypescript-strict-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allegro%2Ftypescript-strict-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allegro%2Ftypescript-strict-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allegro","download_url":"https://codeload.github.com/allegro/typescript-strict-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254169650,"owners_count":22026213,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["strict-mode","ts-strict","typescript","typescript-compiler","typescript-library","typescript-plugin"],"created_at":"2024-08-17T08:07:25.895Z","updated_at":"2025-05-14T15:07:24.686Z","avatar_url":"https://github.com/allegro.png","language":"TypeScript","readme":"# Typescript strict mode plugin\n\nTypescript plugin that allows turning on strict mode in specific files or directories.\n\n## Do I need this plugin?\n\n`typescript-strict-plugin` was created mainly for existing projects that want to incorporate\ntypescript strict mode, but project is so big that refactoring everything would take ages.\n\nOur plugin allows adding strict mode to a TypeScript project without fixing all the errors at once.\nBy adding `//@ts-strict-ignore` comment at the top of a file, its whole content will be removed from\nstrict type checking. To ease migrating a project to use this plugin, you can use\n`update-strict-comments` script, which adds the ignore comment to all files that contain at least\none strict error.\n\nTypeScript plugins don't work at compile-time. They will show errors in your IDE, but they won't\nappear during compilation. To check strict errors in marked files you can use `tsc-strict` script.\nThis command line tool is created to check for files that should be checked with strict rules in\ncompilation time. It finds all relevant files and checks for strict typescript errors only for that\nfiles. Therefore, we have strict errors inside our files and during build time.\n\n## How to install\n\nUse `npm`:\n\n```bash\nnpm i --save-dev typescript-strict-plugin\n```\n\nor yarn\n\n```bash\nyarn add -D typescript-strict-plugin\n```\n\nadd plugin to your `tsconfig.json`:\n\n```json\n{\n \"compilerOptions\": {\n   ...\n   \"strict\": false,\n   \"plugins\": [\n    {\n     \"name\": \"typescript-strict-plugin\"\n    }\n   ]\n }\n}\n```\n\nand run the migration script\n\n```\n./node_modules/.bin/update-strict-comments\n```\n\nThat's it! You should be able to see strict typechecking in files without the `@ts-strict-ignore`\ncomment. To make these files strict too, just remove its' ignore comments.\n\n## Configuration\n\nPlugin takes extra, non-mandatory arguments `paths`, `exclude` and `excludePattern`. Args `paths` and\n`exclude` accept an array of relative or absolute paths that should be included (property `paths`)\nor excluded (property `exclude`). Arg `excludePattern` accepts an array of strings that will be\nmatched with [minimatch](https://github.com/isaacs/minimatch). To add strict mode to files from\nignored paths you can insert `//@ts-strict` comment.\n\n```json\n{\n  \"compilerOptions\": {\n    ...\n    \"strict\": false,\n    \"plugins\": [\n      {\n        \"name\": \"typescript-strict-plugin\",\n        \"paths\": [\n          \"./src\",\n          \"/absolute/path/to/source/\"\n        ],\n        \"exclude\": [\n          \"./src/tests\",\n          \"./src/fileToExclude.ts\"\n        ],\n        \"excludePattern\": [\n          \"**/*.spec.ts\"\n        ]\n      }\n    ]\n  }\n}\n```\n\nAll files contained in those paths will be strictly checked. Yay!\n\nTo add cli tool to your build time you can add a script to scripts list in package.json\n\n```json\n{\n  \"scripts\": {\n    ...,\n    \"typecheck\": \"tsc \u0026\u0026 tsc-strict\",\n  },\n}\n```\n\nThen you can simply run\n\n```shell\nyarn tsc-strict\n```\n\nAll your strict files should be checked from command line.\n\nYou can also pass some `tsc` arguments to the `tsc-strict` to override default compiler options e.g.\n\n```shell\nyarn tsc-strict --strictNullChecks false\n```\n\nwould not check for the strict null check in your files. The `tsc-strict` accepts all the arguments\nthat regular `tsc` command accepts.\n\n## Migrating to v2\n\nBecause of difficulties with migrating large projects to strict mode with original `//@ts-strict`\ncomment, we've taken an another approach. Now in version 2.0+ typescript files are strict by\ndefault, and to ignore a file, you can use special `//@ts-strict-ignore` comment. It allows to have\nstrict mode in newly created files without remembering about adding strict comment at the top of it.\nVersion 2.0 comes with a new script `update-strict-comments`, which detects all files with at least\none strict error and adds the ignore comment to ease the migration. To update from v1 to v2, you\njust need to run:\n\n```\nupdate-strict-comments\n```\n\n## VSCode support\n\nVSCode supports this plugin out of the box. However, sometimes it can use its own typescript version\ninstead of the project one, resulting in not reading the local tsconfig. If you are using VSCode be\nsure to have `Use workspace version` option selected in `Typescript: Select Typescript Version...`\ncommand available in the\n[command pallete](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette).\n\n\u003cimg width=\"729\" alt=\"image\" src=\"https://user-images.githubusercontent.com/35625949/153884371-e0f488d4-05b8-4b88-93d2-1caa7e6081f7.png\"\u003e\n\n## Testing the plugin\n\n### Manually\n\nrun\n\n```bash\nnpm i\n```\n\ninside root folder and `sample-project` folder and then run\n\n```bash\nnpm run build\n```\n\nor\n\n```bash\nnpm run dev\n```\n\nand restart typescript service inside `sample-project`. Files in `sample-project` folder should use\na local plugin. After you made changes to a plugin you should probably restart typescript service in\norder to reload the plugin.\n\n### Tests\n\nIn order to run tests run\n\n```bash\nnpm run test\n```\n\n## Contributing\n\nFeel free to create PR's and issues.\n","funding_links":[],"categories":["typescript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallegro%2Ftypescript-strict-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallegro%2Ftypescript-strict-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallegro%2Ftypescript-strict-plugin/lists"}