Skip to content

Add tsgo as an opt-in fast type-checker#556

Merged
kriszyp merged 3 commits into
mainfrom
kris/tsgo-fast-check
Jul 9, 2026
Merged

Add tsgo as an opt-in fast type-checker#556
kriszyp merged 3 commits into
mainfrom
kris/tsgo-fast-check

Conversation

@kriszyp

@kriszyp kriszyp commented Jul 9, 2026

Copy link
Copy Markdown
Member

Summary

Companion to harper PR #1738. Wires up tsgo (TypeScript 7's native/Go-ported preview compiler) as a new opt-in npm run typecheck:fast script (plus a plain typecheck script for a stable baseline, per review) — invoked via npx, not a package.json dependency (see below).

Purpose

Benchmarked on this codebase (including the core/ submodule): tsgo --noEmit is ~7.2x faster than tsc --noEmit (3.17s → 0.44s). Usage is opt-in — the committed build script (still tsc, 5.x) is behaviorally untouched, though it shares this same tsconfig.json with the new script (harper-pro doesn't split build/check configs the way harper does).

Two tsconfig.json changes were needed, both verified byte-identical against tsc --noEmit before/after (isolated on one commit, config swapped in/out — 29/29 errors, no new/fixed errors either way):

  • Removed "baseUrl": "." — TypeScript 7 hard-errors on it (TS5102, "Option baseUrl has been removed"). The existing "paths": {"@/*": ["./dist/*"]} is already relative and resolves identically without it; confirmed no bare imports anywhere in this repo (including the core/**/* included paths) rely on the baseUrl fallback.
  • Pinned "strict": false" explicitly — this repo already had "noImplicitAny": false" as one strict sub-flag, but relied on tsc's implicit default (false) for the rest. TypeScript 7 flips that default to true; pinning it documents the status quo rather than changing behavior, and forward-guards a future compiler bump.

Not a devDependency (resolved review thread with @cb1kenobi): an earlier version of this PR added @typescript/native-preview as a plain devDependency. Chris correctly pointed out that made npm ci fetch this exact nightly tarball for every CI job (unit, integration, smoke, stress), not just the opt-in checker — if that specific tarball is ever pruned from the registry, all of those jobs would fail, not just typecheck:fast. optionalDependencies doesn't fix this either: both harper and harper-pro are genuinely public npm packages (verified against the registry — no private field), so that would install-attempt this dev-only tool for every real end-user's npm install. Chris's suggested fix — invoke it on demand via npx -y -p @typescript/native-preview@<pinned-version> tsgo ... instead of adding it as a dependency at all — confines a pruned-tarball failure to typecheck:fast alone, matching its actually-opt-in nature. Trade-off: no package-lock.json integrity-hash pinning for this tool (the version is still pinned in the npx invocation itself, just not hash-verified against a lockfile entry).

Where to focus review attention

  • The baseUrl removal touches the tsconfig that also drives the real build — verified inert (see above), but flagging since it's shared config, not an isolated checker-only file.
  • Same 4 known tsgo findings as harper (this repo's core/ is the same submodule code) plus one more: replication/subscriptionManager.ts hits the same manageThreads.js dynamic-export resolution gap. None introduced by this PR; the manageThreads ones are already fixed as a side effect of harper chore: Sync Core #562's CJS→ESM conversion once that lands.

Generated by Claude (Opus 4.8).

Companion to the same change in harper. Wires TypeScript 7's native
compiler preview (tsgo, via @typescript/native-preview) in as a
parallel `npm run typecheck:fast` script -- ~7x faster than tsc on
this codebase, verified on the current tree (including the core/
submodule). Purely additive: the committed `build` script (tsc,
still 5.x) is untouched in behavior, though it shares this tsconfig.json
with the new script (see below).

tsconfig.json changes, both verified byte-identical against tsc
--noEmit before/after (same commit, config swapped in/out):
- Removes `"baseUrl": "."` -- TypeScript 7 hard-errors on baseUrl
  (TS5102). The existing `"paths": {"@/*": ["./dist/*"]}` is already
  relative and resolves identically without it; confirmed no bare
  imports in this repo relied on the baseUrl fallback.
- Pins `"strict": false` explicitly, documenting the current implicit
  default (this repo already had `noImplicitAny: false` as one strict
  sub-flag) so TypeScript 7's flip of the strict default to true
  doesn't silently change results on a future compiler bump.

No harper-pro-level dependencies.md exists (only core/dependencies.md,
which belongs to the untouched vendored submodule), so no entry was
added there -- see PR description for the dependency justification.

Co-Authored-By: Claude <noreply@anthropic.com>
@kriszyp kriszyp requested a review from cb1kenobi July 9, 2026 15:10
@socket-security

socket-security Bot commented Jul 9, 2026

Copy link
Copy Markdown

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@claude

claude Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Reviewed; no blockers found.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the @typescript/native-preview package and adds a fast type-checking script (typecheck:fast) using tsgo. It also updates tsconfig.json by explicitly disabling strict mode and removing the deprecated baseUrl option. The feedback suggests adding a standard typecheck script using tsc to serve as a stable baseline for comparison.

Comment thread package.json Outdated
Addresses Gemini review feedback -- gives a standing baseline to
compare tsgo against tsc, rather than requiring an ad hoc invocation.

Co-Authored-By: Claude <noreply@anthropic.com>
@kriszyp kriszyp marked this pull request as ready for review July 9, 2026 15:54
@kriszyp kriszyp requested a review from a team as a code owner July 9, 2026 15:54
Comment thread package.json Outdated
Addresses cb1kenobi's review: as a plain devDependency, npm ci fetched
this nightly tarball for every CI job (unit, integration, smoke,
stress), not just the opt-in typecheck:fast script. Running it via
`npx -y -p @typescript/native-preview@<pinned-version> tsgo ...`
confines a pruned-tarball failure to typecheck:fast alone, matching
its actually-opt-in nature. Trade-off: no package-lock.json
integrity-hash pinning for this tool (version is still pinned in the
npx invocation itself).

Co-Authored-By: Claude <noreply@anthropic.com>
@kriszyp kriszyp merged commit 1d7a510 into main Jul 9, 2026
33 checks passed
@kriszyp kriszyp deleted the kris/tsgo-fast-check branch July 9, 2026 23:49
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