Skip to content

Typecheck with tsrs instead of TypeScript 7 tsc - #5861

Merged
SawyerHood merged 3 commits into
mainfrom
tsrs-typecheck
Oct 20, 2026
Merged

SawyerHood merged 3 commits into
mainfrom
tsrs-typecheck

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Typechecking ran on TypeScript 7.0.2 (typescript-7 → npm:typescript@^7.0.2). tsrs, the Rust port of the TypeScript 7 compiler, is roughly twice as fast and uses half the memory on bb (numbers below). This PR moves bb's typechecking to it.

tsrs 0.18.0 is a faithful port of TypeScript 7.1.0-dev.20260930.4 and prints the same diagnostics. Moving to it therefore also moves bb onto a 7.1 nightly, which brings two upstream regressions. tsrs also has no Windows binary yet:

  1. TS5115 on zod's z.json() ("Instantiations of the following types appear infinitely circular: 'IsOptionalIn', '$ZodTypeInternals', '$InferZodRecordInput'"). Reported as TS5115 in published Zod 4.5–4.6 types after #64372 microsoft/TypeScript#64605. The first nightly that fails is 7.1.0-dev.20260929.1, after Restore idempotency to resolveObjectTypeMembers microsoft/TypeScript#64372.
  2. TS7031 on a contextually typed destructured parameter with = {}. Reported as TS7031 false positive for nested object binding pattern with = {} default in an annotated parameter (regression from #64043) microsoft/TypeScript#64431, with fixes proposed in Fix false implicit-any errors in annotated nested bindings microsoft/TypeScript#64440 and Do not pad binding elements that the parameter's type already types microsoft/TypeScript#64671. The first nightly that fails is 7.1.0-dev.20260923.1.
  3. No win32-x64 package through 0.18.0. tsrs's npm/README.md says its release workflow now builds one. Intel Macs remain unsupported.

What changed

  • tsrs replaces TypeScript 7 for typechecking. Every package.json that listed typescript-7 now lists tsrs pinned to 0.18.0-ts7.1.0-dev.20260929 (exact pin because the releases are experimental), and every typecheck script runs tsrs --noEmit. typescript (the @typescript/typescript6 JS API) stays for tooling that imports it.
  • Workaround for regression 1. Core code uses jsonValueSchema/jsonObjectSchema from @bb/domain instead of z.json(): apps/desktop (CDP + capture, plus two tests) and packages/desktop-contract. Forkable plugins can't import @bb/domain, so account-pool, bb-account, connect, mcp and workflows each define the same z.lazy schema, typed with the SDK's JsonValue. That schema has the same structure as zod's z.json(), so runtime validation is unchanged. The only remaining z.json() calls are in two tests that don't trigger the error.
  • Workaround for regression 2. The abort-signal mock in system-config-atoms.local-access.test.ts annotates its parameter.
  • Windows. The windows-foundation job now runs lint test without typecheck. The Windows typecheck steps in build-desktop.yml and the nightly-desktop-windows job are removed. plugin-authoring-doc-examples.test.ts now launches tsrs and skips on win32. Types don't depend on the OS, and the Linux static-checks job still typechecks every package. These can come back once tsrs publishes win32-x64.
  • Left alone: the plugin scaffold's typescript dependency for user plugins, and the bb-app tarball smoke test's npx typescript consumer check. Both stand in for what plugin authors and SDK users run.

How you verified

  • pnpm exec turbo run typecheck --force --continue on tsrs: 105/105 pass. Before the workarounds, 7 failed, with 16 TS5115 errors and 1 TS7031.

  • Every changed package also passes tsc --noEmit on TypeScript 7.0.2.

  • Both regressions reproduce on tsc 7.1.0-dev.20260930.4 and today's 7.1.0-dev.20261020.3, and pass on 7.0.2. I found the first failing nightly for each by trying successive builds.

  • turbo run lint test for @bb/desktop, @bb/desktop-contract, account-pool, bb-account, connect, bb--mcp and workflows: 16/16 pass. The doc-examples test passes with tsrs, and the system-config atoms test passes (12/12).

  • Speed, same machine, warm, --noEmit, best of two runs:

    package tsc (TS 7.0.2) tsrs
    apps/server 11.3s, 3.3 GB 5.5s, 1.6 GB
    apps/app 11.4s, 3.4 GB 6.4s, 1.7 GB
  • pnpm install --frozen-lockfile is clean, and oxfmt --check passes.

AGENT GENERATED

Replace the typescript-7 (npm:typescript@^7) devDependency with tsrs
0.18.0-ts7.1.0-dev.20260929, the Rust port of the TypeScript 7 compiler,
and run `tsrs --noEmit` in every typecheck script. The TypeScript 6 JS API
package stays for tooling that imports `typescript`.
tsrs follows TypeScript 7.1-dev, which reports TS5115 on zod's z.json()
(microsoft/TypeScript#64605) and TS7031 on a contextually typed
destructured parameter with a `= {}` default (microsoft/TypeScript#64431).

- Core code uses @bb/domain's jsonValueSchema/jsonObjectSchema instead of
  z.json(); forkable plugins define the same z.lazy schema locally, typed
  with the SDK's JsonValue. Runtime validation matches z.json().
- Annotate the abort-signal mock parameter in the system-config atoms test.
- tsrs ships no Windows binary through 0.18.0, so the Windows CI jobs
  (windows-foundation, desktop build, nightly desktop) stop typechecking and
  the doc-examples compile test skips on win32. Linux CI still typechecks
  every package.
@SawyerHood
SawyerHood marked this pull request as ready for review October 20, 2026 16:50
Forkable plugins are copied out of the monorepo and installed alone, so a
package that runs `tsrs --noEmit` must declare tsrs itself instead of
relying on the workspace root.
@SawyerHood
SawyerHood merged commit 75b90b9 into main Oct 20, 2026
47 of 48 checks passed
@SawyerHood
SawyerHood deleted the tsrs-typecheck branch October 20, 2026 17:17
ymichael pushed a commit that referenced this pull request Oct 20, 2026
#5640 added @bb/query-tags with a typescript-7 (npm:typescript@^7.0.2)
dev dependency. #5861 merged first and removed typescript@7.0.2 from the
lockfile when it moved every package to tsrs. The merged lockfile kept
the importer entry without a package entry, so pnpm install
--frozen-lockfile fails with ERR_PNPM_LOCKFILE_MISSING_DEPENDENCY.

Move query-tags to tsrs like every other package.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants