ALL INTELLIGENCE
Hacker News AIT2·Tools

Vercel Labs Releases Experimental Native Port of TypeScript Compiler

Original title: tsc-ts: TypeScript written in TypeScript
42AI Score

Vercel Labs released tsc-ts, an experimental native port of the TypeScript 7.0.2 compiler (TypeScript-Go/tsgo). Compiled to native code via scriptc, it offers per-platform binaries through npm, aiming to explore high-performance compilation paths.

Full Report

Contents8 sections

tsc-ts

<p> [<img alt="Vercel Labs Experiment" src="https://img.shields.io/badge/LABS-EXPERIMENT-0a0a0a.svg?style=for-the-badge&amp;logo=Vercel&amp;labelColor=000000" height="28">](https://vercel.com/labs#active-experiments) [<img alt="License: Apache-2.0" src="https://img.shields.io/github/license/vercel-labs/tsc-ts.svg?style=for-the-badge&amp;labelColor=000000" height="28">](https://github.com/vercel-labs/tsc-ts/blob/main/LICENSE) </p>

An experimental TypeScript port of the TypeScript 7.0.2 compiler (TypeScript-Go, or tsgo), compiled to native code with scriptc.

Installation

Install the compiler from npm:

BASH
npm install -D tsc-ts
npx tsc-ts -p tsconfig.json

The tsc-ts package runs a native executable from a per-platform optional dependency (@tsc-ts/darwin-arm64, @tsc-ts/linux-x64-gnu, …). See packages/tsc-ts.

See CHANGELOG.md for release notes and GitHub Releases for package archives.

To build the packages for the current platform:

BASH
npm run pack:npm -w tsc-ts             # packages/tsc-ts/dist/npm/*.tgz
npm run pack:npm -w tsc-ts -- --check  # also install the tarballs and compile a project

-- --binary dist/tsc packs an existing native build, relative to packages/tsc-ts, instead of building one.

Packages

PackageDescription
packages/tsc-tsThe compiler, written in TypeScript, with the tsc-ts command line and --api server.
packages/tsgoReference builds of tsgo (its command line and per-stage drivers) that the tests compare against.

Tasks run with Turborepo.

Documentation

apps/web contains the tsc-ts compiler guides.

BASH
npm run dev:web
npm run build:web

Requirements

  • Node.js 24+ and npm
  • Go 1.26
  • A scriptc host: macOS, Linux, or Windows, with clang available for linking

Build

BASH
npm ci
npm run fetch:upstream   # clone tsgo at the pinned commit
npm run build            # the Node build of tsc-ts (packages/tsc-ts/dist) and the documentation site
npm run build:oracle     # tsgo reference builds in packages/tsgo/dist

package.json pins scriptc 0.3.5, with its @scriptc/threads package. The build fails with any other version.

Compiler

packages/tsc-ts/src/compiler is the compiler, ported from tsgo 7.0.2 as idiomatic TypeScript. Each part is compared with tsgo on TypeScript's test corpus (about 12,500 files, 17,000 units after splitting multi-file cases):

PartCompared with tsgoStatus
Scannertokens, values, errors, rescans, JSDocall files match
Parser and ASTtree, diagnostics, API source file encodingall units match
Bindersymbols, tables, flow graph, name resolutionall units match
Module resolutionresults, package IDs, --traceResolutionall requests match
tsconfig.json and programs--showConfig, --listFilesOnly, --explainFilesall cases match
Command line and optionsoutput, errors, exit codes, --localeall cases match
Diagnostics catalogmessages, 13 translations, output formatsall match
JavaScript emitemitted files, 39 option setsall compared units match
Declaration emit.d.ts and .d.ts.map output, declaration errorsall units match
--build, --incrementaloutput, .tsbuildinfo, emitted files, --watchall scenarios match
Type checkerdiagnostics per fileall files match

The corpus scripts are in packages/tsc-ts/scripts (*-corpus.mjs).

API server

tsc-ts --api serves the same API as TypeScript 7.0.2's tsc --api, over stdin and stdout, so tools that drive tsc --api (such as scriptc) can run tsc-ts instead.

BASH
npm run build -w tsc-ts
node packages/tsc-ts/dist/tsc-ts/src/main.js --api --cwd path/to/project

Native builds read lib files from the executable's directory, or from TSC_TS_LIB_DIR:

BASH
npm run build:native -w tsc-ts       # packages/tsc-ts/dist/tsc
npm run build:native:dev -w tsc-ts   # unoptimized, faster to build
TSC_TS_LIB_DIR=upstream/typescript-go/internal/bundled/libs packages/tsc-ts/dist/tsc -p path/to/project

TSC_TS_BIN=packages/tsc-ts/dist/tsc runs the tsc-ts tests that take a native build against it.

The server is checked against tsc --api 7.0.2 response by response, and scriptc builds the same programs with either. It runs on the tsc-ts compiler, natively or under Node.

Language service methods are supported: getCompletionsAtPosition, getJsDocTags, getDocumentationComment, getReferencesToSymbolInFile, getReferencedSymbolsForNode and getSignatureUsages. Like tsc --api, completions that need auto imports (global identifiers, import statements, exhaustive switch cases) report completion list needs auto imports. The profiling methods (startCPUProfile, stopCPUProfile, saveHeapProfile) are not supported.

Testing

BASH
npm test                     # compare tsc-ts with tsgo
npm run bench -w tsc-ts      # time tsc-ts against tsgo and TypeScript's JavaScript compiler
npm run lint                 # oxlint
npm run format               # oxfmt