Skip to content

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

Merged
kriszyp merged 6 commits into
mainfrom
kris/tsgo-fast-check
Jul 10, 2026
Merged

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

Conversation

@kriszyp

@kriszyp kriszyp commented Jul 9, 2026

Copy link
Copy Markdown
Member

Summary

Adds @typescript/native-preview (ships tsgo, the native/Go-ported preview compiler that becomes TypeScript 7's tsc) as a devDependency and wires it in as a new npm run typecheck:fast script.

Purpose

Benchmarked on this exact codebase: tsgo --noEmit is ~6.3x faster than tsc --noEmit (3.01s → 0.48s) with the same result set, and the emit path is ~6.7x faster too. This gives a much faster local/CI type-check loop as an opt-in parallel tool — it does not replace or touch the committed build script (tsc --project tsconfig.build.json), and does not touch ESLint (@typescript-eslint/parser still needs typescript 5.x, since TypeScript 7.0 ships no compiler API — 7.1 will).

Also pins "strict": false explicitly in tsconfig.json. The repo never set strict, relying on tsc's implicit default (false); TypeScript 7 flips that default to true. Verified tsc --noEmit output is byte-identical before/after this pin — it documents the status quo rather than changing behavior, and forward-guards against a future compiler bump silently changing type-check results.

Where to focus review attention

  • tsgo is pinned to an exact nightly -dev build (7.0.0-dev.20260707.2), not a caret range. Nightly preview tags on the npm registry aren't guaranteed to persist indefinitely — if the tarball is ever pruned, a clean-cache npm ci would fail until the pin is bumped. Low impact (dev-only, opt-in, not a CI gate) but worth knowing about.
  • The dependencies.md entry notes tsgo ships a prebuilt native (Go-compiled) binary via platform-gated optionalDependencies — no local compilation, but it's not a pure-JS package either.
  • 4 known type-check findings surfaced by tsgo today (none introduced by this PR, none blocking): a module-export resolution gap on server/threads/manageThreads.js's dynamic module.exports.X = ... pattern (2 sites — already fixed as a side effect of Add type-strip mode: run Harper directly from .ts sources #562's CJS→ESM conversion, once that lands), plus two independent findings (security/auth.ts, server/REST.ts's Buffer/BufferSource typing) worth a separate look but out of scope here.

Generated by Claude (Opus 4.8).

Wires TypeScript 7's native compiler preview (tsgo, via
@typescript/native-preview) in as a parallel `npm run typecheck:fast`
script -- ~6-7x faster than tsc on this codebase, verified on the
current tree. Purely additive: the committed build (tsconfig.build.json)
and ESLint (@typescript-eslint/parser, still needs typescript 5.x since
TS7 ships no compiler API) are untouched.

Also pins `"strict": false` explicitly in tsconfig.json, documenting the
current implicit default so TypeScript 7's flip of that default to true
doesn't silently change type-check results on a future compiler bump.
Verified byte-identical `tsc --noEmit` output before/after this pin.

Co-Authored-By: Claude <noreply@anthropic.com>
@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

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

Copy link
Copy Markdown
Contributor

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 @typescript/native-preview as a devDependency and adds a typecheck:fast script to run the native TypeScript compiler preview (tsgo). It also documents this dependency and explicitly sets "strict": false in tsconfig.json to avoid issues with future compiler upgrades. The reviewer suggested pinning the new dependency to the stable beta release (7.0.0-beta) instead of a nightly -dev build to prevent potential installation failures if the npm registry prunes old nightly tarballs.

Comment thread package.json Outdated
@claude

claude Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Reviewed; no blockers found.

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 16:09
Kris Zyp and others added 2 commits July 9, 2026 10:10
Addresses cb1kenobi's review on the companion harper-pro PR (#556):
the typecheck:fast *script* is opt-in, but @typescript/native-preview
as a plain devDependency means npm ci fetches this exact nightly
tarball for every CI job, not just the checker. Documents why
optionalDependencies isn't the fix (both harper and harper-pro are
genuinely public npm packages, so it would leak this dev-only tool
into every real end-user install) and formalizes accepting the
pruning risk knowingly.

Co-Authored-By: Claude <noreply@anthropic.com>
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>
Comment thread package.json Outdated
… tsgo fast-check (#1738)

TypeScript 7 merges the native (Go-ported) compiler preview directly into
typescript's own tsc binary, so the separate @typescript/native-preview
package/tsgo binary is no longer needed once 7.0.2 is out. Still invoked
via npx (not a package.json dependency) since typescript is already a 5.x
devDependency here and npx resolves/caches the pinned 7.x tarball
separately without colliding with it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@kriszyp kriszyp merged commit e41ec1c into main Jul 10, 2026
46 of 49 checks passed
@kriszyp kriszyp deleted the kris/tsgo-fast-check branch July 10, 2026 02:53
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