Skip to content

perf(typecheck): run the native TypeScript 7 compiler - #6356

Merged
waleedlatif1 merged 1 commit into
stagingfrom
worktree-typecheck-perf
Aug 7, 2026
Merged

perf(typecheck): run the native TypeScript 7 compiler#6356
waleedlatif1 merged 1 commit into
stagingfrom
worktree-typecheck-perf

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • tsc was silently resolving to the JavaScript TypeScript 6 compiler, not the native TypeScript 7 one we already pin. apps/sim needs @typescript/typescript6 for its runtime TypeScript AST API, and that pulls in @typescript/old (an alias of typescript@6) which declares its own tsc bin. Package managers pick bin winners by lexical sort, not dependency depth, so @typescript/old beat typescript and won node_modules/.bin/tsc.
  • Identical diagnostics, ~10x slower, and it fails silently — the check still passes, it just burns minutes on every dev machine and every CI run.
  • Fix is the TypeScript team's own recommendation on typescript-go#4567 (the original blog example was wrong): a root @typescript/native alias that sorts ahead of @typescript/old. Every type-check script is unchanged, and bunx tsc / ad-hoc invocations are fixed too.
  • Dropped NODE_OPTIONS=--max-old-space-size=8192 from apps/sim's type-check — it only ever mattered for the JS compiler's V8 heap.
  • Added check:native-typecheck to CI. The alias is invisible-load-bearing: nothing imports it, so removing it looks like dead-dependency cleanup and costs 10x with no visible failure.
before after
apps/sim cold 83s 8.5s
all 23 workspaces cold 96s 9.4s
apps/sim warm 2.9s

Type of Change

  • Improvement

Testing

Verified both compilers check an identical 11,066-source-file program with byte-identical diagnostics — the only --listFiles delta is lib relocation plus TS7 deduping nested .d.ts copies, zero source files dropped.

  • All 23 workspaces pass; injected a type error and confirmed it's still caught and the exit code propagates through turbo
  • Confirmed a stale TS6 .tsbuildinfo (17MB) does not cause a false pass under the native compiler
  • Reproduced the bin collision in an isolated project and confirmed the alias fixes it on bun 1.3.14
  • Confirmed the guard fails by actually removing the alias and reinstalling
  • No dependency version change — @typescript/native resolves to the same typescript@7.0.2 tarball already in the lockfile

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

A bare `tsc` was silently resolving to the JavaScript TypeScript 6 compiler.
`apps/sim` depends on `@typescript/typescript6` for its runtime TypeScript AST
API, which pulls in `@typescript/old` (an alias of `typescript@6`) declaring its
own `tsc` bin. Package managers pick bin winners by lexical sort rather than
dependency depth, so `@typescript/old` beat `typescript` and won
`node_modules/.bin/tsc`.

Identical diagnostics, ~10x slower, and it fails silently: the check still
passes, it just burns minutes. Both compilers check an identical 11,066-source-
file program with byte-identical diagnostics; the only `--listFiles` delta is
lib relocation plus TS7 deduping nested .d.ts copies.

The `@typescript/native` alias sorts ahead of `@typescript/old` and reclaims the
bin. This is the TypeScript team's own recommendation on typescript-go#4567 --
the original blog example was wrong. Every `type-check` script is unchanged;
`bunx tsc` and ad-hoc invocations are fixed too.

apps/sim cold 83s -> 8.5s; all 23 workspaces 96s -> 9.4s.

The alias is invisible-load-bearing: nothing imports it, so removing it looks
like dead-dependency cleanup and costs 10x with no visible failure.
check:native-typecheck asserts a bare `tsc` reports 7.x and fails CI otherwise.

Also drops NODE_OPTIONS=--max-old-space-size=8192 from apps/sim's type-check --
it only ever mattered for the JS compiler's V8 heap.
@waleedlatif1
waleedlatif1 requested a review from a team as a code owner August 7, 2026 00:29
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Building Building Preview Aug 7, 2026 12:29am

Request Review

@cursor

cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
No runtime or application logic changes; only dependency aliasing, CI audit script, and documentation. Risk is limited to misconfigured tsc resolution if the alias is removed later — which the new check is meant to catch.

Overview
Bare tsc was resolving to the JavaScript TypeScript 6 binary from @typescript/old (pulled in by @typescript/typescript6 in apps/sim), not native TS 7 — same diagnostics but ~10× slower, with no visible failure.

This adds a root @typescript/native devDependency alias so node_modules/.bin/tsc wins the lexical bin sort, drops the NODE_OPTIONS heap bump from apps/sim’s type-check script (only needed for the JS compiler), and wires check:native-typecheck into CI before turbo run type-check.

Agent docs and skills now tell contributors to run bun run type-check instead of ad-hoc bunx tsc, with notes in CLAUDE.md and global.md explaining why the alias must stay.

Reviewed by Cursor Bugbot for commit 016f153. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR makes the repository’s bare tsc command resolve to the native TypeScript 7 compiler and adds a CI guard against silently falling back to TypeScript 6.

  • Adds a root @typescript/native alias and updates the Bun lockfile.
  • Audits the selected compiler before the workspace type-check job.
  • Removes the obsolete V8 heap setting from apps/sim.
  • Updates contributor and agent documentation to use workspace type-check scripts.

Confidence Score: 5/5

The PR appears safe to merge, with the compiler audit covering the bin-selection regression it is intended to prevent.

The audit invokes the same root tsc shim used by workspace scripts, CI runs it after dependency installation and before type-checking, and the command and configuration changes preserve the checked projects.

Important Files Changed

Filename Overview
package.json Adds the compiler audit command and root alias needed to win Bun’s tsc bin selection.
bun.lock Resolves the new alias to the same native TypeScript 7.0.2 package already used by the repository.
scripts/check-native-typecheck.ts Verifies that the exact root tsc shim used by workspace scripts reports TypeScript 7.x.
.github/workflows/test-build.yml Runs the compiler-selection audit immediately before the monorepo type-check.
apps/sim/package.json Removes a V8 heap option that does not apply to the native Go compiler.
CLAUDE.md Documents the required type-check commands and the load-bearing dependency alias.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Install["bun install"] --> Alias["@typescript/native alias"]
  Alias --> Shim["node_modules/.bin/tsc"]
  Audit["check:native-typecheck"] --> Shim
  Shim --> Version{"Reports TypeScript 7.x?"}
  Version -->|Yes| Typecheck["Turbo workspace type-checks"]
  Version -->|No| Fail["Fail CI before type-checking"]
Loading

Reviews (1): Last reviewed commit: "perf(typecheck): run the native TypeScri..." | Re-trigger Greptile

@waleedlatif1
waleedlatif1 merged commit a512a26 into staging Aug 7, 2026
23 of 24 checks passed
@waleedlatif1
waleedlatif1 deleted the worktree-typecheck-perf branch August 7, 2026 00:33
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.

1 participant