@rsbuild/plugin-type-check
Runs TypeScript type checking for Rsbuild builds in a separate process, logging errors in dev and failing production builds on real type errors.
Repository Health
Technical Analysis
@rsbuild/plugin-type-check wires ts-checker-rspack-plugin into an Rsbuild project so TypeScript type checking happens out-of-band from the main compilation, keeping incremental builds fast while still catching type errors. It reads the project’s tsconfig.json automatically, understands TypeScript project references, and can also drive the newer native TypeScript 7 checker (tsgo) when a compatible typescript version is installed, falling back to the classic tsc-based checker otherwise.
The plugin is deliberately asymmetric about how it treats errors: in development mode, type errors are only logged to the terminal and reported to the Rsbuild dev server overlay so they never block iteration, while in production builds the same errors cause the build to fail, preventing type-unsafe code from shipping. Options let teams tune this behavior further — disabling the plugin entirely, scoping it to a single environment, excluding specific files or error codes, or passing through raw ts-checker-rspack-plugin configuration for advanced setups such as multiple tsconfig files or Vue’s vue-tsc-based checking.
What You Get
- Automatic tsconfig.json discovery per Rsbuild environment, including support for TypeScript project references
- Non-blocking type errors in development (logged to terminal and the Rsbuild error overlay) vs. build-failing errors in production
- Optional native TypeScript 7 (tsgo) checker support for faster type checking on large codebases
- Fine-grained exclude rules for ignoring type errors by file path or TypeScript error code
- Pass-through configuration object or function for full control over the underlying ts-checker-rspack-plugin options
Common Use Cases
- Catching type errors before they reach production without adding tsc as a separate CI step
- Keeping fast Rsbuild dev-server rebuilds while still surfacing type errors in the browser overlay
- Adopting the TypeScript 7 native checker (tsgo) for quicker checks on large monorepos
- Type-checking Vue single-file components via the vue-tsc-based typescript path override
- Selectively silencing known/legacy type errors during a gradual TypeScript migration
Under The Hood
Architecture
The plugin is a single Rsbuild plugin object (src/index.ts) that hooks into api.modifyBundlerChain. On each bundler-chain pass it reads the active environment’s tsconfigPath, guards against re-checking an identical tsconfig for the same environment via a Map, parses the tsconfig with json5 to detect TypeScript project references, builds a default ts-checker-rspack-plugin options object (readonly mode, 8GB memory limit, node_modules exclusion, a custom logger that relabels ERROR/WARNING output), merges it with any user-supplied tsCheckerOptions via reduce-configs and deepmerge, and finally registers TsCheckerRspackPlugin on the Rspack chain. All actual type-checking logic — the readonly/build split, native tsgo detection, issue filtering — is delegated to ts-checker-rspack-plugin, keeping this package a thin, focused integration layer.
Tech Stack
Written in TypeScript targeting ES2023, built and packaged with the rstack CLI (dual ESM/CJS output via its lib build target). Runtime dependencies are minimal and purpose-built: deepmerge for merging option objects, json5 for tolerant tsconfig parsing (which permits comments/trailing commas), reduce-configs for resolving the plugin’s config-chain option shape, and ts-checker-rspack-plugin as the actual checker implementation. @rsbuild/core and @typescript/native-preview are optional peer dependencies, letting consumers opt into the newer native TypeScript 7 checker without forcing it on everyone.
Code Quality
Tests use @rstest/playwright end-to-end style: each scenario under test/ (basic, exclude-node-modules, multiple-tsconfig, typescript-go, typescript-v7) spins up a real Rsbuild instance against a fixture project, runs a build or dev server, and asserts on captured console output or the browser’s error overlay content — a black-box style that exercises the plugin exactly as a consumer would. CI runs a dedicated lint workflow (rs lint) and a test workflow on every PR/push to main, plus a tag-triggered release workflow with OIDC npm publishing. The codebase is fully typed, uses the project’s shared rstack lint/format config, and pre-commit staged linting is configured via define.staged in rstack.config.ts.
What Makes It Unique
Rather than reimplementing TypeScript checking, the plugin’s value is entirely in its dev/prod asymmetry policy and its early, low-friction adoption path for TypeScript 7’s native (tsgo) checker — a checker still new enough that most competing bundler-plugin ecosystems have not yet wired it in as a drop-in upgrade path alongside the classic tsc-based one.
Used by 2 apps in this directory
Refly
No Code Platforms · AI Development · Automation
Build deterministic, versioned agent skills from natural language—run them anywhere from Claude Code to Slack.
Webiny JS
Ecommerce · Blogging · CMS
Open-source, self-hosted CMS on AWS serverless — a TypeScript framework you extend with code, not a product you configure through a UI.