From 4fbfe4411385df866dd6d06ec425a28640218ef5 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 21 Nov 2026 11:40:07 +0000 Subject: [PATCH 1/6] docs(tsrs): expand the type checker guide --- src/docs/guide/usage/typechecker.md | 94 ++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 10 deletions(-) diff --git a/src/docs/guide/usage/typechecker.md b/src/docs/guide/usage/typechecker.md index 2e6adbbe8f2..a3f6a9610e3 100644 --- a/src/docs/guide/usage/typechecker.md +++ b/src/docs/guide/usage/typechecker.md @@ -1,13 +1,13 @@ --- title: Type Checker -description: Check TypeScript types with tsrs, a Rust port of the TypeScript compiler. +description: Use tsrs to type-check and build TypeScript projects, power your editor, and run type-aware linting with Oxlint. outline: deep --- # Type Checker -::: info Experimental -`tsrs` is experimental. It aims for full TypeScript compatibility, but some differences remain. See the [compatibility status](https://github.com/oxc-project/tsrs/blob/main/docs/COMPATIBILITY.md) for supported features and known gaps. +::: info TypeScript compatibility +`tsrs` currently targets TypeScript 7.1 beta. See the [compatibility status](https://github.com/oxc-project/tsrs/blob/main/docs/COMPATIBILITY.md) for supported features and known gaps. ::: [`tsrs`](https://github.com/oxc-project/tsrs) is a Rust port of the TypeScript compiler and language server, incubated as part of Oxc. Cloudflare, VoidZero, and Max Schwenk are developing it in collaboration with the TypeScript team. @@ -16,37 +16,111 @@ The goal is faster type checking and lower memory use while preserving upstream ## Quickstart -Install [`tsrs`](https://npmx.dev/package/tsrs) as a development dependency: +Install [`tsrs`](https://npmx.dev/package/tsrs) as a development dependency and run it from your project directory. The compiler reads your existing `tsconfig.json`. Pass `--noEmit` to check types without writing JavaScript or declaration files. ::: code-group ```sh [npm] -$ npm add -D tsrs +npm add -D tsrs +npm exec -- tsrs --noEmit ``` ```sh [pnpm] -$ pnpm add -D tsrs +pnpm add -D tsrs +pnpm exec tsrs --noEmit ``` ```sh [yarn] -$ yarn add -D tsrs +yarn add -D tsrs +yarn exec tsrs --noEmit ``` ```sh [bun] -$ bun add -D tsrs +bun add -D tsrs +bun run tsrs --noEmit ``` ::: -Run it from your project directory to check types without emitting JavaScript: +## Check a project + +Use `-p` (`--project`) to select a directory containing `tsconfig.json` or to pass a config file directly. Add `--watch` to recheck after files change. + +```sh +pnpm exec tsrs --noEmit -p packages/web/tsconfig.json +pnpm exec tsrs --noEmit --watch -p packages/web/tsconfig.json +``` + +Watch mode is available on Linux and macOS. See the [watch mode compatibility notes](https://github.com/oxc-project/tsrs/blob/main/docs/DEFAULTS.md#watch-mode). + +For local development and CI, add a script to `package.json` so both environments run the same check with the version from your lockfile. + +```json +{ + "scripts": { + "typecheck": "tsrs --noEmit" + } +} +``` + +Run `pnpm run typecheck` after installing dependencies. The command exits with a nonzero status when it reports type errors. If incremental compilation is enabled, `--noEmit` can still write a `.tsbuildinfo` cache file. See the [emit documentation](https://github.com/oxc-project/tsrs/blob/main/docs/EMIT.md) for details. + +## Emit JavaScript and declarations + +Run `tsrs -p` with emit enabled in your config to compile one project. Compiler options such as `outDir`, `declaration`, and `sourceMap` control where files are written and which outputs are generated. For a config with TypeScript project references, use `--build` to build the referenced projects in dependency order. [Compiler CLI guide](https://github.com/oxc-project/tsrs/blob/main/docs/USAGE.md) + +```sh +pnpm exec tsrs -p packages/web/tsconfig.json +pnpm exec tsrs --build tsconfig.json +pnpm exec tsrs --build --watch tsconfig.json +``` + +## Lint and type-check with Oxlint + +Oxlint 1.92.0 and later automatically use `tsrs` for type-aware linting when it is installed. Add `--type-check` to report TypeScript compiler diagnostics for the files Oxlint lints. The two checks share one TypeScript analysis. See the [type-aware linting guide](./linter/type-aware) for configuration details. + +```sh +pnpm add -D oxlint tsrs +pnpm exec oxlint --type-aware --type-check +``` + +Use a standalone `tsrs --noEmit` check when CI needs diagnostics for every file in the TypeScript project, including files that Oxlint skips. [Type checking in the lint run](https://github.com/oxc-project/tsrs/blob/main/tools/tsgolint/README.md#type-checking-in-the-lint-run) + +## Fast mode + +The standalone compiler defaults to the checker settings of the TypeScript release it ports. Pass `--fast` to enable adaptive checker counts, additional caches, and memory optimizations. The preset keeps compiler options such as `strict` and `skipLibCheck` as configured. ```sh -npx tsrs --noEmit +pnpm exec tsrs --noEmit --fast ``` +Fast mode can change diagnostics for programs sensitive to checking order or type-instantiation limits. Try the same command with `--fast false` when investigating a difference. The Oxlint backend enables fast mode by default and accepts `TSRS_FAST=0` to disable it. See the [performance options](https://github.com/oxc-project/tsrs/blob/main/docs/USAGE.md#performance-options) and [benchmark results](https://github.com/oxc-project/tsrs/blob/main/bench/RESULTS.md). + +## Use tsrs in your editor + +`tsrs` includes a language server for diagnostics, completions, and navigation. On macOS and Linux, install the [TypeScript Native Preview extension](https://marketplace.visualstudio.com/items?itemName=TypeScriptTeam.native-preview) for VS Code and point it at the SDK from your project dependency in `.vscode/settings.json`. + +```json +{ + "js/ts.experimental.useTsgo": true, + "js/ts.tsdk.path": "./node_modules/tsrs/tsdk" +} +``` + +For Windows and other editors, see the [language server setup guide](https://github.com/oxc-project/tsrs/blob/main/docs/LSP.md#editor-setup). + +## Troubleshoot compatibility + +- If your config uses legacy options such as `baseUrl`, check which options TypeScript 7 removed and how to migrate them. See the [TypeScript migration guide](https://github.com/microsoft/TypeScript/issues/62508#issuecomment-3348649259). +- Use an existing config or create `tsconfig.json` by hand. `tsrs --init` is currently unsupported. See [differences from upstream TypeScript](https://github.com/oxc-project/tsrs/blob/main/docs/DEFAULTS.md). +- If the launcher cannot find the native binary, check that your install includes optional dependencies. See the [compatibility table](https://github.com/oxc-project/tsrs/blob/main/docs/COMPATIBILITY.md) for supported platforms. +- If diagnostics differ from upstream, run `pnpm exec tsrs --version` to identify the TypeScript version and commit to compare against. Include the version, command, and a minimal reproduction in your [bug report](https://github.com/oxc-project/tsrs/issues). + ## Links - [`tsrs` repository](https://github.com/oxc-project/tsrs) - [CLI usage](https://github.com/oxc-project/tsrs/blob/main/docs/USAGE.md) +- [Node.js API](https://github.com/oxc-project/tsrs/blob/main/docs/NODE_API.md) +- [WebAssembly for Node.js and browsers](https://github.com/oxc-project/tsrs/blob/main/npm/tsrs-wasm/README.md) - [Browser playground](https://tsrs-playground.void.app) - [Introducing tsrs: A port of TypeScript to Rust](https://blog.cloudflare.com/typescript-rust-port/) From 03255d24e273296486fff7938d8d41ef2ee832fb Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 21 Nov 2026 11:41:56 +0000 Subject: [PATCH 2/6] docs: simplify the tsrs quickstart --- src/docs/guide/usage/typechecker.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/docs/guide/usage/typechecker.md b/src/docs/guide/usage/typechecker.md index a3f6a9610e3..ec7f6ffd1cc 100644 --- a/src/docs/guide/usage/typechecker.md +++ b/src/docs/guide/usage/typechecker.md @@ -16,28 +16,28 @@ The goal is faster type checking and lower memory use while preserving upstream ## Quickstart -Install [`tsrs`](https://npmx.dev/package/tsrs) as a development dependency and run it from your project directory. The compiler reads your existing `tsconfig.json`. Pass `--noEmit` to check types without writing JavaScript or declaration files. +Install [`tsrs`](https://npmx.dev/package/tsrs) and run it from your project directory. ::: code-group ```sh [npm] npm add -D tsrs -npm exec -- tsrs --noEmit +npm exec tsrs ``` ```sh [pnpm] pnpm add -D tsrs -pnpm exec tsrs --noEmit +pnpm exec tsrs ``` ```sh [yarn] yarn add -D tsrs -yarn exec tsrs --noEmit +yarn exec tsrs ``` ```sh [bun] bun add -D tsrs -bun run tsrs --noEmit +bun run tsrs ``` ::: From 100b7f923debba264a7ff43db19049688baf15b6 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 21 Nov 2026 11:42:36 +0000 Subject: [PATCH 3/6] docs: trim redundant tsrs project setup --- src/docs/guide/usage/typechecker.md | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/docs/guide/usage/typechecker.md b/src/docs/guide/usage/typechecker.md index ec7f6ffd1cc..0735b8cbeac 100644 --- a/src/docs/guide/usage/typechecker.md +++ b/src/docs/guide/usage/typechecker.md @@ -16,7 +16,7 @@ The goal is faster type checking and lower memory use while preserving upstream ## Quickstart -Install [`tsrs`](https://npmx.dev/package/tsrs) and run it from your project directory. +Install [`tsrs`](https://npmx.dev/package/tsrs) and run it in place of `tsc` from your project directory. ::: code-group @@ -42,29 +42,6 @@ bun run tsrs ::: -## Check a project - -Use `-p` (`--project`) to select a directory containing `tsconfig.json` or to pass a config file directly. Add `--watch` to recheck after files change. - -```sh -pnpm exec tsrs --noEmit -p packages/web/tsconfig.json -pnpm exec tsrs --noEmit --watch -p packages/web/tsconfig.json -``` - -Watch mode is available on Linux and macOS. See the [watch mode compatibility notes](https://github.com/oxc-project/tsrs/blob/main/docs/DEFAULTS.md#watch-mode). - -For local development and CI, add a script to `package.json` so both environments run the same check with the version from your lockfile. - -```json -{ - "scripts": { - "typecheck": "tsrs --noEmit" - } -} -``` - -Run `pnpm run typecheck` after installing dependencies. The command exits with a nonzero status when it reports type errors. If incremental compilation is enabled, `--noEmit` can still write a `.tsbuildinfo` cache file. See the [emit documentation](https://github.com/oxc-project/tsrs/blob/main/docs/EMIT.md) for details. - ## Emit JavaScript and declarations Run `tsrs -p` with emit enabled in your config to compile one project. Compiler options such as `outDir`, `declaration`, and `sourceMap` control where files are written and which outputs are generated. For a config with TypeScript project references, use `--build` to build the referenced projects in dependency order. [Compiler CLI guide](https://github.com/oxc-project/tsrs/blob/main/docs/USAGE.md) @@ -75,6 +52,8 @@ pnpm exec tsrs --build tsconfig.json pnpm exec tsrs --build --watch tsconfig.json ``` +Watch mode is available on Linux and macOS. See the [watch mode compatibility notes](https://github.com/oxc-project/tsrs/blob/main/docs/DEFAULTS.md#watch-mode). + ## Lint and type-check with Oxlint Oxlint 1.92.0 and later automatically use `tsrs` for type-aware linting when it is installed. Add `--type-check` to report TypeScript compiler diagnostics for the files Oxlint lints. The two checks share one TypeScript analysis. See the [type-aware linting guide](./linter/type-aware) for configuration details. From ba7167f6fde52f994be7425b9edc6a03fbf28b88 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 21 Nov 2026 11:43:02 +0000 Subject: [PATCH 4/6] docs: name TypeScript 7.1 as the comparison baseline --- src/docs/guide/usage/typechecker.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/guide/usage/typechecker.md b/src/docs/guide/usage/typechecker.md index 0735b8cbeac..c354067a7d0 100644 --- a/src/docs/guide/usage/typechecker.md +++ b/src/docs/guide/usage/typechecker.md @@ -93,7 +93,7 @@ For Windows and other editors, see the [language server setup guide](https://git - If your config uses legacy options such as `baseUrl`, check which options TypeScript 7 removed and how to migrate them. See the [TypeScript migration guide](https://github.com/microsoft/TypeScript/issues/62508#issuecomment-3348649259). - Use an existing config or create `tsconfig.json` by hand. `tsrs --init` is currently unsupported. See [differences from upstream TypeScript](https://github.com/oxc-project/tsrs/blob/main/docs/DEFAULTS.md). - If the launcher cannot find the native binary, check that your install includes optional dependencies. See the [compatibility table](https://github.com/oxc-project/tsrs/blob/main/docs/COMPATIBILITY.md) for supported platforms. -- If diagnostics differ from upstream, run `pnpm exec tsrs --version` to identify the TypeScript version and commit to compare against. Include the version, command, and a minimal reproduction in your [bug report](https://github.com/oxc-project/tsrs/issues). +- When comparing diagnostics, use TypeScript 7.1 beta at the upstream commit shown by `pnpm exec tsrs --version`. If the results differ, include the version, command, and a minimal reproduction in your [bug report](https://github.com/oxc-project/tsrs/issues). ## Links From 0d5670d625df97ed947b011149ab1975212932a3 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 21 Nov 2026 11:45:57 +0000 Subject: [PATCH 5/6] docs: include tsrs lint benchmark results --- src/docs/guide/usage/typechecker.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/docs/guide/usage/typechecker.md b/src/docs/guide/usage/typechecker.md index c354067a7d0..f3a0140f768 100644 --- a/src/docs/guide/usage/typechecker.md +++ b/src/docs/guide/usage/typechecker.md @@ -65,6 +65,8 @@ pnpm exec oxlint --type-aware --type-check Use a standalone `tsrs --noEmit` check when CI needs diagnostics for every file in the TypeScript project, including files that Oxlint skips. [Type checking in the lint run](https://github.com/oxc-project/tsrs/blob/main/tools/tsgolint/README.md#type-checking-in-the-lint-run) +In our type-aware linting benchmarks, Oxlint with `tsrs` ran up to 5× as fast as with `tsgolint` v7.0.2007 and used around 70% less memory. See the [benchmarks in the announcement](/blog/2026-11-17-faster-type-aware-linting-with-tsrs#performance). + ## Fast mode The standalone compiler defaults to the checker settings of the TypeScript release it ports. Pass `--fast` to enable adaptive checker counts, additional caches, and memory optimizations. The preset keeps compiler options such as `strict` and `skipLibCheck` as configured. From afb9e4f3bdba3479fe7c48c5a9d12db8227f17cc Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 21 Nov 2026 11:46:32 +0000 Subject: [PATCH 6/6] docs: remove redundant tsrs emit instructions --- src/docs/guide/usage/typechecker.md | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/docs/guide/usage/typechecker.md b/src/docs/guide/usage/typechecker.md index f3a0140f768..03d1f7a8f7b 100644 --- a/src/docs/guide/usage/typechecker.md +++ b/src/docs/guide/usage/typechecker.md @@ -16,7 +16,7 @@ The goal is faster type checking and lower memory use while preserving upstream ## Quickstart -Install [`tsrs`](https://npmx.dev/package/tsrs) and run it in place of `tsc` from your project directory. +Install [`tsrs`](https://npmx.dev/package/tsrs) and use it as you would `tsc`. ::: code-group @@ -42,18 +42,6 @@ bun run tsrs ::: -## Emit JavaScript and declarations - -Run `tsrs -p` with emit enabled in your config to compile one project. Compiler options such as `outDir`, `declaration`, and `sourceMap` control where files are written and which outputs are generated. For a config with TypeScript project references, use `--build` to build the referenced projects in dependency order. [Compiler CLI guide](https://github.com/oxc-project/tsrs/blob/main/docs/USAGE.md) - -```sh -pnpm exec tsrs -p packages/web/tsconfig.json -pnpm exec tsrs --build tsconfig.json -pnpm exec tsrs --build --watch tsconfig.json -``` - -Watch mode is available on Linux and macOS. See the [watch mode compatibility notes](https://github.com/oxc-project/tsrs/blob/main/docs/DEFAULTS.md#watch-mode). - ## Lint and type-check with Oxlint Oxlint 1.92.0 and later automatically use `tsrs` for type-aware linting when it is installed. Add `--type-check` to report TypeScript compiler diagnostics for the files Oxlint lints. The two checks share one TypeScript analysis. See the [type-aware linting guide](./linter/type-aware) for configuration details.