Skip to content

chore(frontend): use TypeScript 7 native compiler for type-checking#1460

Open
danyelf wants to merge 1 commit into
mainfrom
feature/ts7-native-typecheck
Open

chore(frontend): use TypeScript 7 native compiler for type-checking#1460
danyelf wants to merge 1 commit into
mainfrom
feature/ts7-native-typecheck

Conversation

@danyelf

@danyelf danyelf commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

PR checklist

  • Ensure you have added or ran the appropriate tests for your PR.
  • DCO signed

What type of PR is this?

chore — frontend build tooling / dependencies.

What this PR does / why we need it:

TypeScript 7 shipped — it's the native (Go) compiler and is dramatically faster than the JS-based tsc. This adopts it for type-checking, both locally and in CI, without breaking the build tools that still depend on the old compiler's API.

The catch: TypeScript 7.0 ships no programmatic API (a new one is slated for 7.1). Anything that does require('typescript') — Next.js's build-time type check and tsdown's .d.ts generation — breaks on a bare typescript@7. So a naive bump is a non-starter.

The fix is Microsoft's recommended dual-install, which keeps both compilers side by side:

  • typescriptnpm:@typescript/typescript6 — the JS-based 6.x compiler. Keeps the programmatic API alive for Next and tsdown. Its binary is exposed as tsc6.
  • typescript-7npm:typescript@7 — the native compiler. Provides the tsc binary that pnpm type:check runs.

Net effect: pnpm type:check — locally and in the release-ui CI job — now runs the fast native compiler, while Next's build and the @datarecce/ui .d.ts build keep working against the JS API. On this repo, tsc --noEmit drops from ~2.3–6.2s (JS) to ~0.9s (native).

No CI workflow file changes are needed: the alias makes tsc resolve to the native binary automatically, and the lockfile records all platform builds so pnpm install --frozen-lockfile on the Linux runner pulls the correct one (@typescript/typescript-linux-x64).

Which issue(s) this PR fixes:

None — opportunistic tooling upgrade.

Special notes for your reviewer:

  • Don't "simplify" the alias away. Three pins must stay in lockstep: the two typescript devDependencies (root js/package.json and js/packages/ui/package.json) and the typescript: override in js/pnpm-workspace.yaml. Reverting any to a plain typescript@7 reintroduces the no-API breakage. This is documented in js/CLAUDE.md.
  • The native compiler is CLI-only here; the JS 6.x compiler still does all API work (Next type-check, tsdown). So language semantics are unchanged — TS 7.0 is a semantics-identical port of 6.x, no new language features.
  • Verified locally: pnpm lint, pnpm type:check, pnpm test (4042 pass), pnpm run build (Next + tsdown), and CI=true pnpm install --frozen-lockfile all pass.

Does this PR introduce a user-facing change?:

NONE

Adopt the native (Go) TypeScript 7 compiler for `tsc`, which speeds up
type-checking locally and in the release-ui CI job, while keeping the
JS-based compiler available for the tools that still need its API.

TypeScript 7 is a native rewrite that ships no programmatic API until
7.1, so a bare `typescript@7` breaks Next's build-time type check and
tsdown's .d.ts generation (both call `require('typescript')`). The fix
is Microsoft's recommended dual-install:

  - `typescript`   -> npm:@typescript/typescript6 (JS 6.x, keeps the API;
                      binary is `tsc6`)
  - `typescript-7` -> npm:typescript@7 (native; provides the `tsc` binary
                      that `pnpm type:check` runs)

Net effect: `pnpm type:check` (and CI's release-ui type-check step) now
run the fast native compiler, and Next/tsdown keep working against the
JS API. On this repo `tsc --noEmit` drops from ~2.3-6.2s (JS) to ~0.9s
(native). No CI workflow change is needed -- the alias makes `tsc`
resolve to the native binary; the lockfile records all platform builds
so `--frozen-lockfile` on the Linux runner pulls the right one.

Three version pins move together: the two devDependencies (root and
packages/ui) plus the `typescript:` override in pnpm-workspace.yaml.
Documented in js/CLAUDE.md so the alias isn't mistaken for a mistake.

Verified: lint, type:check, tsdown build, next build, 4042 vitest tests,
and a frozen-lockfile install all pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Danyel Fisher <danyel@gmail.com>
@danyelf danyelf requested a review from gcko July 8, 2026 21:28
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