{"id":14693321,"url":"https://github.com/rspack-contrib/rsbuild-plugin-type-check","last_synced_at":"2025-09-07T21:06:29.003Z","repository":{"id":255845477,"uuid":"853724982","full_name":"rspack-contrib/rsbuild-plugin-type-check","owner":"rspack-contrib","description":"An Rsbuild plugin to run TypeScript type checker in a separate process.","archived":false,"fork":false,"pushed_at":"2025-08-07T17:11:28.000Z","size":194,"stargazers_count":7,"open_issues_count":5,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-08-08T21:57:18.536Z","etag":null,"topics":["rsbuild","rsbuild-plugin","rspack"],"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/rspack-contrib.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"zenodo":null}},"created_at":"2024-09-07T11:06:25.000Z","updated_at":"2025-08-03T14:09:53.000Z","dependencies_parsed_at":"2024-09-07T12:47:51.159Z","dependency_job_id":"1354a302-4c7d-44f3-b64d-76a2a6541574","html_url":"https://github.com/rspack-contrib/rsbuild-plugin-type-check","commit_stats":null,"previous_names":["rspack-contrib/rsbuild-plugin-type-check"],"tags_count":8,"template":false,"template_full_name":"rspack-contrib/rsbuild-plugin-template","purl":"pkg:github/rspack-contrib/rsbuild-plugin-type-check","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-type-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-type-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-type-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-type-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rspack-contrib","download_url":"https://codeload.github.com/rspack-contrib/rsbuild-plugin-type-check/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-type-check/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274095421,"owners_count":25221433,"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","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["rsbuild","rsbuild-plugin","rspack"],"created_at":"2024-09-13T02:01:13.440Z","updated_at":"2025-09-07T21:06:28.993Z","avatar_url":"https://github.com/rspack-contrib.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Rsbuild Plugins"],"readme":"# @rsbuild/plugin-type-check\n\nAn Rsbuild plugin to run TypeScript type checker in a separate process.\n\n\u003cp\u003e\n  \u003ca href=\"https://npmjs.com/package/@rsbuild/plugin-type-check\"\u003e\n   \u003cimg src=\"https://img.shields.io/npm/v/@rsbuild/plugin-type-check?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"npm version\" /\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"license\" /\u003e\n  \u003ca href=\"https://npmcharts.com/compare/@rsbuild/plugin-type-check?minimal=true\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/@rsbuild/plugin-type-check.svg?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"downloads\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cimg width=\"1472\" alt=\"Screenshot 2025-02-14 at 23 08 37\" src=\"https://github.com/user-attachments/assets/15d38419-34af-4a69-8841-8f9c608d8b68\" /\u003e\n\n## Introduction\n\nThis plugin internally integrates with [ts-checker-rspack-plugin](https://github.com/rspack-contrib/ts-checker-rspack-plugin).\n\nThe type checking logic of `ts-checker-rspack-plugin` is similar to the native `tsc` command of TypeScript. It automatically reads the configuration options from `tsconfig.json` and can also be modified via the configuration options provided by the Type Check plugin.\n\nThe behavior of the plugin differs in the development and production builds:\n\n- In development mode, type errors do not block the build process. They are only logged in the terminal.\n- In production mode, type errors cause the build to fail in order to ensure the stability of the production code.\n\n## Usage\n\nInstall:\n\n```bash\nnpm add @rsbuild/plugin-type-check -D\n```\n\nAdd plugin to your `rsbuild.config.ts`:\n\n```ts\n// rsbuild.config.ts\nimport { pluginTypeCheck } from \"@rsbuild/plugin-type-check\";\n\nexport default {\n  plugins: [pluginTypeCheck()],\n};\n```\n\n### Configuring tsconfig.json\n\nThe Type Check plugin by default performs checks based on the `tsconfig.json` file in the root directory of the current project. Below is an example of a `tsconfig.json` file, which you can also adjust according to the needs of your project.\n\n```json title=\"tsconfig.json\"\n{\n  \"compilerOptions\": {\n    \"target\": \"ES2020\",\n    \"lib\": [\"DOM\", \"ES2020\"],\n    \"module\": \"ESNext\",\n    \"strict\": true,\n    \"skipLibCheck\": true,\n    \"isolatedModules\": true,\n    \"resolveJsonModule\": true,\n    \"moduleResolution\": \"bundler\"\n  },\n  \"include\": [\"src\"]\n}\n```\n\nPlease note that the fields in `tsconfig.json` will not affect the compilation behavior and output of Rsbuild, but will only affect the results of type checking.\n\n## Options\n\n### enable\n\nWhether to enable TypeScript type checking.\n\n- **Type:** `boolean`\n- **Default:** `true`\n- **Example:**\n\nDisable TypeScript type checking:\n\n```js\npluginTypeCheck({\n  enable: false,\n});\n```\n\nEnable type checking only in production mode:\n\n```js\npluginTypeCheck({\n  enable: process.env.NODE_ENV === \"production\",\n});\n```\n\nEnable type checking only in development mode (it is not recommended to disable type checking in production mode, as it may reduce the stability of the production code):\n\n```js\npluginTypeCheck({\n  enable: process.env.NODE_ENV === \"development\",\n});\n```\n\n### tsCheckerOptions\n\nModify the options of `ts-checker-rspack-plugin`, please refer to [ts-checker-rspack-plugin - README](https://github.com/rspack-contrib/ts-checker-rspack-plugin#readme) to learn about available options.\n\n- **Type:** `Object | Function`\n- **Default:**\n\n```ts\nconst defaultOptions = {\n  typescript: {\n    // set 'readonly' to avoid emitting tsbuildinfo,\n    // as the generated tsbuildinfo will break ts-checker-rspack-plugin\n    mode: \"readonly\",\n    // enable build when using project reference\n    build: useReference,\n    // avoid OOM issue\n    memoryLimit: 8192,\n    // use tsconfig of user project\n    configFile: tsconfigPath,\n    // use typescript of user project\n    typescriptPath: require.resolve(\"typescript\"),\n  },\n  issue: {\n    // ignore types errors from node_modules\n    exclude: [({ file = \"\" }) =\u003e /[\\\\/]node_modules[\\\\/]/.test(file)],\n  },\n  logger: {\n    log() {\n      // do nothing\n      // we only want to display error messages\n    },\n    error(message: string) {\n      console.error(message.replace(/ERROR/g, \"Type Error\"));\n    },\n  },\n};\n```\n\n#### Object Type\n\nWhen the value of `tsCheckerOptions` is an object, it will be deeply merged with the default configuration.\n\n```ts\npluginTypeCheck({\n  tsCheckerOptions: {\n    issue: {\n      exclude: [({ file = \"\" }) =\u003e /[\\\\/]some-folder[\\\\/]/.test(file)],\n    },\n  },\n});\n```\n\n#### Function Type\n\nWhen the value of `tsCheckerOptions` is a function, the default configuration will be passed as the first argument. You can directly modify the configuration object or return an object as the final configuration.\n\n```ts\npluginTypeCheck({\n  tsCheckerOptions(options) {\n    options.async = false;\n    return options;\n  },\n});\n```\n\n#### exclude Example\n\nThe `exclude` option can filter based on the `code`, `message`, or `file` from TS errors.\n\nFor example, the type mismatch error can be excluded using `code: 'TS2345'`:\n\n```ts\npluginTypeCheck({\n  tsCheckerOptions: {\n    issue: {\n      // Ignore \"Argument of type 'string' is not assignable to parameter of type 'number'.ts(2345)\"\n      exclude: [{ code: \"TS2345\" }],\n    },\n  },\n});\n```\n\nOr exclude files under `/some-folder/` using `file`:\n\n```ts\npluginTypeCheck({\n  tsCheckerOptions: {\n    issue: {\n      exclude: [({ file = \"\" }) =\u003e /[\\\\/]some-folder[\\\\/]/.test(file)],\n    },\n  },\n});\n```\n\n#### Disable type errors from the error overlay\n\nBy default, type errors will be reported to Dev Server and displayed in the Rsbuild error overlay in development mode.\n\nIf you don't want type errors to be displayed in the error overlay, you can disable it by setting `devServer: false`:\n\n```ts\npluginTypeCheck({\n  tsCheckerOptions: {\n    async: true,\n    devServer: false,\n  },\n});\n```\n## Notes\n\n- If you have enabled `ts-loader` in your project and manually configured `compileOnly: false`, please disable the Type Check plugin to avoid duplicate type checking.\n- Some errors will be displayed as warnings in IDEs such as VS Code, but they will still be displayed as errors in the `ts-checker-rspack-plugin` check. For details, please refer to: [Why are some errors reported as warnings?](https://code.visualstudio.com/docs/typescript/typescript-compiling#_why-are-some-errors-reported-as-warnings).\n\n## Performance Optimization\n\nType checking has a significant performance overhead. You can refer to the [Performance Guide](https://github.com/microsoft/TypeScript/wiki/Performance) in the official TypeScript documentation for performance optimization.\n\nFor example, properly configuring the `include` and `exclude` scopes in `tsconfig.json` can significantly reduce unnecessary type checking and improve TypeScript performance:\n\n```json title=\"tsconfig.json\"\n{\n  \"include\": [\"src\"],\n  \"exclude\": [\"**/node_modules\", \"**/.*/\"]\n}\n```\n\n## Vue Components\n\nTo enable typecheck in `.vue` files, use the custom TypeScript wrapper [`@esctn/vue-tsc-api`](https://www.npmjs.com/package/@esctn/vue-tsc-api). It works on top of [`vue-tsc`](https://www.npmjs.com/package/vue-tsc) — a popular CLI tool for type-checking Vue 3 code.\n\n```bash\nnpm add @esctn/vue-tsc-api -D\n```\n\n```js\npluginTypeCheck({\n  tsCheckerOptions: {\n    typescript: {\n      typescriptPath: '@esctn/vue-tsc-api'\n    }\n  },\n});\n```\n\n## License\n\n[MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspack-contrib%2Frsbuild-plugin-type-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frspack-contrib%2Frsbuild-plugin-type-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspack-contrib%2Frsbuild-plugin-type-check/lists"}