Skip to content

chore: TypeScript 7 beta build:ts7 harness (benchmarking)#8657

Draft
paulbalaji wants to merge 2 commits intomainfrom
pbio/ts7-beta-benchmark
Draft

chore: TypeScript 7 beta build:ts7 harness (benchmarking)#8657
paulbalaji wants to merge 2 commits intomainfrom
pbio/ts7-beta-benchmark

Conversation

@paulbalaji
Copy link
Copy Markdown
Collaborator

@paulbalaji paulbalaji commented Apr 22, 2026

Summary

  • Adds @typescript/native-preview@7.0.0-dev.20260421.2 (TS 7 beta, CLI = tsgo) as a root devDep + catalog entry.
  • Mirrors each TS-compiling package's build script as build:ts7 with tsc swapped for tsgo (27 packages across typescript/, solidity/, starknet/).
  • Adds a build:ts7 turbo task and root pnpm build:ts7 so both compilers run against the same tree.
  • Not a TS 6 replacement — regular pnpm build still uses tsc from the existing typescript: 6.0.2 catalog entry.

Draft PR — opened to compare cold build time between the existing tsc and tsgo.

Benchmark results (local, macOS arm64)

Measured with pnpm -w turbo run clean && /usr/bin/time -p pnpm <task> --force after both compilers were fully installed. Each path runs all 29 workspace build tasks (TS + hardhat compile + typechain + prisma + tailwindcss + forge tron build).

Build Wall User CPU Sys CPU Turbo reported
pnpm build (tsc 6.0.2) 130.3 s 300.4 s 29.7 s 2 m 9.5 s
pnpm build:ts7 (tsgo 7.0.0-dev) 90.5 s 206.6 s 23.7 s 1 m 29.7 s
Warm pnpm build (turbo cache hit) 4.3 s 2.5 s
Warm pnpm build:ts7 (turbo cache hit) 3.4 s 2.6 s

tsgo is ~30% faster end-to-end on the full cold monorepo build (130 s → 90 s wall, ~40 s absolute). User-CPU reduction is similar (~31 %). Warm numbers are cache-dominated and uninformative.

The actual per-package tsc → tsgo speedup is larger than 30 % — the cold build wall time includes non-TS work (forge/tron compile, hardhat/typechain for core + helloworld, prisma codegen, tailwindcss) that runs identically in both paths.

Why native-preview vs. a typescript@7-beta bump

Per the TS 7 beta announcement, TS 7 beta ships under @typescript/native-preview with the tsgo binary; the stable release will eventually publish under typescript. No drop-in replacement exists today. Keeping both installed side-by-side is the cleanest way to benchmark.

Build fixes required to reach parity

Getting build:ts7 green on all 29 tasks required three code changes. These are real behavioral differences between tsc 6.0.2 and tsgo 7.0.0-dev.20260421.2, not tooling issues:

  1. @ts-expect-error / @ts-ignore scope differs. tsc 6 applies the directive to the full next statement; tsgo 7 applies it only to the immediate next line. For a multi-line new Transaction({ ... }) call where a single property (blockhash) violates the ctor type, no single directive position satisfies both. Fixed by extracting the object literal into an intermediate variable, which bypasses excess-property checks in both compilers without casts. Affects 3 call sites (sdk/SealevelCrossCollateralAdapter.ts, sdk/SealevelTokenAdapter.ts, helloworld/sealevelAdapter.ts).
  2. core#build:tron dependency restructuring. The existing build:tron → build turbo edge caused core#build and core#build:ts7 to run concurrently in the TS 7 path, racing on hardhat-esm / typechain output (MalformedAbiError: Not a json). solidity/turbo.json now overrides build:tron to depend on deps:soldeer directly; build-tron.sh only needs soldeer, not the tsc output.
  3. Turbo build:ts7 task wiring. tron-sdk/turbo.json mirrors its existing build override to depend on @hyperlane-xyz/core#build:tron, and solidity/turbo.json declares the build:ts7 task.

Notes

  • pnpm minimumReleaseAge (7 days) blocks TS 7 dev builds, so @typescript/native-preview and @typescript/native-preview-* (platform binaries) are added to minimumReleaseAgeExclude.
  • No tsconfig changes — repo has no target: es5, no baseUrl, no legacy module: amd/umd/systemjs/none (the other TS 7 breaking changes).
  • widgets splits build:ts7-only + build:css to mirror its existing build:ts + build:css pattern.

Test plan

  • pnpm install succeeds on a clean checkout
  • pnpm exec tsgo --version reports 7.0.0-dev
  • pnpm build (TS 6, cold): 29/29 tasks succeed, 130 s wall
  • pnpm build:ts7 (TS 7, cold): 29/29 tasks succeed, 90 s wall
  • Directive-position fixes build cleanly under both tsc 6 and tsgo 7
  • CI confirms on linux-x64 runner hardware

Adds `@typescript/native-preview` (TS 7 beta, `tsgo`) as a root devDep
and mirrors each package's `build` script as `build:ts7`, swapping
`tsc` for `tsgo`. Root `pnpm build:ts7` runs the parallel compile via
turbo so the two compilers can be benchmarked against the same tree.

Not a replacement for TS 6 — regular `pnpm build` continues to use
`tsc` from the `typescript` catalog entry.
@socket-security
Copy link
Copy Markdown

socket-security Bot commented Apr 22, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​typescript/​native-preview@​7.0.0-dev.20260421.210010072100100

View full report

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.33%. Comparing base (2496363) to head (4f476d1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8657   +/-   ##
=======================================
  Coverage   79.33%   79.33%           
=======================================
  Files         143      143           
  Lines        4278     4278           
  Branches      436      436           
=======================================
  Hits         3394     3394           
  Misses        855      855           
  Partials       29       29           
Flag Coverage Δ
solidity 80.58% <ø> (ø)
tron-sdk 73.02% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
core 87.80% <ø> (ø)
hooks 78.11% <ø> (ø)
isms 81.46% <ø> (ø)
token 88.00% <ø> (ø)
middlewares 87.76% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…uild:ts7

- Add `build:ts7` to `@hyperlane-xyz/core` and `@hyperlane-xyz/starknet-core`
  (both invoke tsc in their build chain).
- Override `build:tron` in solidity/turbo.json to depend on `deps:soldeer`
  directly rather than `build`. Prevents concurrent `core#build` and
  `core#build:ts7` invocations (which race on hardhat-esm compile output)
  when tron-sdk is in the graph.
- Mirror tron-sdk's `build` turbo override for `build:ts7` so it pulls in
  `core#build:tron` for tron ABI artifacts.
- Rewrite three Solana `new Transaction({...})` call sites that used
  `@ts-expect-error` / `@ts-ignore` to pass `blockhash` + `recentBlockhash`
  together. tsc 6 and tsgo 7 apply the directive at different scopes, so
  neither position satisfies both. Using an intermediate variable bypasses
  the excess-property check in both compilers without casts.
@hyper-gonk
Copy link
Copy Markdown
Contributor

hyper-gonk Bot commented Apr 22, 2026

Node Services Docker Image Built Successfully

Service Tag
node-services 4f476d1-20260422-203211
Full image paths
ghcr.io/hyperlane-xyz/hyperlane-node-services:4f476d1-20260422-203211

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4f476d1. Configure here.

"scripts": {
"hyperlane": "node ./dist/cli.js",
"build": "pnpm version:update && NODE_OPTIONS='--max-old-space-size=4096' tsc",
"build:ts7": "pnpm version:update && NODE_OPTIONS='--max-old-space-size=4096' tsgo",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NODE_OPTIONS is meaningless for Go-based tsgo binary

Low Severity

The build:ts7 script sets NODE_OPTIONS='--max-old-space-size=4096' before invoking tsgo, which is a native Go binary (not a Node.js process). This environment variable is silently ignored by Go. It was mechanically carried over from the build script where it's needed for tsc (a Node.js process). While harmless at runtime, it's misleading — a future reader may assume tsgo requires 4 GB of heap, or try to tune this knob expecting it to affect the Go compiler.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4f476d1. Configure here.

Comment thread solidity/turbo.json
"cache-tron/**",
"artifacts-tron/**",
"dist/tron/typechain/**"
]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New build:tron override silently changes existing build dependency graph

Medium Severity

Adding build:tron to solidity/turbo.json with "dependsOn": ["deps:soldeer"] overrides the root turbo.json definition where build:tron depends on ["build"]. This decouples build:tron from the regular build for the solidity package, allowing them to run in parallel during pnpm build. Previously they ran sequentially. The comment in build-tron.sh line 9 explicitly documents the old invariant: (build:tron depends on build, which depends on deps:soldeer). This behavioral change to the existing build pipeline is unrelated to the TS7 benchmarking goal.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4f476d1. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

1 participant