Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.aspect.build/llms.txt

Use this file to discover all available pages before exploring further.

TypeScript works great with Bazel. The ts_project rule handles type-checking and transpilation, and integrates with your existing tsconfig.json. API reference: TypeScript rules

Configuration

You can use a single tsconfig.json for the whole repository or one per package. You must mirror some tsconfig.json values into your BUILD file—if they don’t match, rules_ts prints an error with the exact command to fix it. For more info, see Configuring TypeScript.

Transpiler

TypeScript transpilation is separate from type-checking, so you can swap in a faster tool like swc or esbuild instead of the default tsc. On the first run, rules_ts suggests .bazelrc settings for your chosen transpiler. See the Transpiling TypeScript into JavaScript.

Isolated declarations

For large monorepos, you can go further by enabling TypeScript’s isolatedDeclarations option. This makes declaration file (.d.ts) generation a single-file transform with no dependencies, so Bazel can run all type-check actions fully in parallel rather than sequentially along the dependency chain. See Isolated Declarations. API reference: TypeScript definitions | ts extensions | ts repositories Troubleshooting: rules_ts troubleshooting | Performance tips
Bazel requires that you explicitly declare all dependencies, including @types/node. This differs from TypeScript’s ambient imports where any types in node_modules are automatically available.

Wrapping ts_project in a macro

Many organizations set default values for ts_project—such as shared tsconfig settings or a standard transpiler—so it’s common to write a macro that wraps ts_project and have developers load that instead of using @aspect_rules_ts directly. See the Macros section of the rules_js documentation for an example of this pattern.

Examples

The rules_ts examples folder has a range of starting points, and the bazel-examples repository includes larger real-world setups for Jest and Angular. For React, see the bazel-build/react example. If you’d like to add an example, fund a Feature Request.

Telemetry

rules_js collects limited usage data through tools_telemetry, reported to Aspect Build, Inc. and governed by the Aspect Privacy Policy.