The Type Check plugin provides the ability to run TypeScript type checks in a separate process. The plugin internally integrates with fork-ts-checker-webpack-plugin.
The type checking logic of fork-ts-checker-webpack-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.
The behavior of the plugin differs in the development and production environments:
You can install the plugin using the following command:
You can register the plugin in the rsbuild.config.ts
file:
Whether to enable TypeScript type checking.
boolean
true
Disable TypeScript type checking:
Enable type checking only during production builds:
Enable type checking only during development builds (it is not recommended to disable type checking during production builds, as it may reduce the stability of the production code):
To modify the options of fork-ts-checker-webpack-plugin
, please refer to [fork-ts-checker-webpack-plugin - README](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin #readme) to learn about available options.
Object | Function
When the value of forkTsCheckerOptions
is an object, it will be deeply merged with the default configuration.
When the value of forkTsCheckerOptions
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.
fork-ts-checker-webpack-plugin
does not support checking TypeScript code in .vue
files.ts-loader
in your project and manually configured compileOnly: false
, please disable the Type Check plugin to avoid duplicate type checking.Type checking has a significant performance overhead. You can refer to the Performance Guide in the official TypeScript documentation for performance optimization.
For example, properly configuring the include
and exclude
scopes in tsconfig.json
can significantly reduce unnecessary type checking and improve TypeScript performance: