tools.tsChecker

  • Type: Object | Function
  • Default:
const defaultOptions = {
  typescript: {
    // avoid OOM issue
    memoryLimit: 8192,
    // use tsconfig of user project
    configFile: tsconfigPath,
    // use TypeScript checker by default
    tsgo: false,
    // use typescript of user project
    typescriptPath: require.resolve('typescript'),
  },
  issue: {
    exclude: [
      { file: '**/*.(spec|test).ts' },
      { file: '**/node_modules/**/*' },
    ],
  },
  logger: {
    log() {
      // do nothing
      // we only want to display error messages
    },
    error(message: string) {
      console.error(message.replace(/ERROR/g, 'Type Error'));
    },
  },
},

By default, the @rsbuild/plugin-type-check is enabled for type checking. You can use output.disableTsChecker config to disable it.

Example

When the value of tsChecker is of type Object, it will be deeply merged with the default configuration.

export default {
  tools: {
    tsChecker: {
      issue: {
        exclude: [({ file = '' }) => /[\\/]some-folder[\\/]/.test(file)],
      },
    },
  },
};

Please refer to @rsbuild/plugin-type-check for more details.

TypeScript Go Support

tools.tsChecker supports enabling TypeScript Go for type checking. This experimental capability is provided by ts-checker-rspack-plugin, which is integrated by @rsbuild/plugin-type-check, and can reduce type-checking time by about 5-10x.

Before using it, install @typescript/native-preview:

npm
yarn
pnpm
bun
deno
npm install @typescript/native-preview -D

Then set typescript.tsgo to true:

export default {
  tools: {
    tsChecker: {
      typescript: {
        tsgo: true,
      },
    },
  },
};

When tsgo is enabled, the default typescript.typescriptPath resolves to @typescript/native-preview/package.json. If you manually set typescript.typescriptPath, it must be an absolute path to @typescript/native-preview/package.json.

For supported options and limitations, please refer to ts-checker-rspack-plugin - TypeScript Go support.