CodeVetter
← All unpacks
CodeVetter · Repo Unpack evidence

microsoft/TypeScript

Scanned commit 5f6db9c914 dated 2026-09-22 — last upstream commit. Generated by codevetter 1.12.0 on 2026-09-22.

github.com/microsoft/TypeScript ↗ · 3997 files · 9.0 MB · scan capped

TypeScript TypeScript is a language for application-scale JavaScript.

Deep analysis by swe-2 via the devin CLI on 2026-09-22 (runtime not recorded) — every claim below links to its cited source files.

Overview

This repo is the native Go port of the TypeScript compiler and language service (TypeScript 7, internally 'Corsa', shipped as tsgo). A single Go module under tsc/ builds one `tsc` binary that runs in three modes: batch compiler (tsc/tsc -b/--watch), an LSP server (`tsc --lsp`), and an IPC API server (`tsc --api`, MessagePack or JSON-RPC) consumed by the `@typescript/typescript` npm package. The repo also ships the `native-preview` ('TypeScript 7') VS Code extension that spawns the Go binary as a language server, plus extensive baseline-test infrastructure ported from the original TypeScript test suite.

System map

The system is one Go module (tsc/, module github.com/microsoft/TypeScript/tsc) in a go.work workspace with a tools/ module, orchestrated by a Node hereby build (Herebyfile.mjs). The single binary at tsc/cmd/tsc multiplexes three runtimes: batch compile via internal/execute, an LSP server via internal/lsp over stdin/stdout, and a programmatic API server via internal/api over stdio or a named pipe. The compiler core is layered scanner/parser/ast -> binder -> checker (parallel checker pool) -> transformers -> emitter/printer/sourcemap, all reading through a vfs.FS abstraction with lib .d.ts files embedded via internal/bundled. Shipping surfaces are the `tsc`/`tsgo` binary, per-platform npm packages wrapped by packages/typescript, and the packages/vscode-typescript VS Code extension.

All 13 system map claims →

Feature catalog

User-facing surface area splits into four groups. (1) The tsc CLI: single-project and build-mode compilation, watch mode, incremental/tsbuildinfo, --init/--showConfig/--listFilesOnly, tracing, pprof, diagnostics statistics. (2) A broad LSP feature set: pull diagnostics, hover, completions with auto-imports, definitions/references/implementations, rename, formatting, code actions, code lenses, inlay hints, semantic tokens, call hierarchy, workspace symbols, folding/selection/linked-editing, willRenameFiles, plus custom debugging and content-mapper methods. (3) A ~300-method programmatic API over IPC (parse, transpile, symbol/type queries, diagnostics, emit). (4) The VS Code extension's commands and settings. Notably, CHANGES.md documents deliberate feature removals versus the Strada compiler (Closure-style JSDoc features, constructor expandos, several removed options).

All 14 feature catalog claims →

Data flow

For the CLI, input is argv -> tsoptions parsing (with ancestor tsconfig discovery and extended-config caching) -> a file loader that walks imports/type directives as parse tasks -> parser.ParseSourceFile producing ast.SourceFile trees -> binder-produced symbols -> a parallel checker pool producing diagnostics -> transformer chain -> printer/sourcemap emit through vfs.FS.WriteFile. For the LSP/API servers the same core is wrapped by internal/project: an immutable Snapshot owns a SnapshotFS overlay plus a ProjectCollection, and every edit/request produces a new snapshot; language-service operations read a snapshot's program. The API server adds a registry layer assigning stable SymbolID/TypeID/NodeHandle values that are encoded to MessagePack or JSON for the Node client.

All 14 data flow claims →

Behavior traces

Three flows were traced end to end. Batch compile: main -> runMain -> execute.CommandLine -> tscCompilation -> tsoptions parse/config discovery -> NewCachedFSCompilerHost -> compiler.NewProgram (processAllProgramFiles -> checker pool) -> EmitAndReportStatistics -> EmitFilesAndReportErrors (bind+check diagnostics, Emit) -> report + exit status. LSP: runLSP -> flag parse -> bundled.WrapFS(osvfs.FS()) -> lsp.NewServer -> Server.Run -> read/dispatch loop -> handlerMap -> project.Session snapshots -> ls.LanguageService. API: runAPI -> StdioServer.Run -> ipc transport accept -> StandaloneSession -> proto method table dispatch. A fourth flow covers watch/incremental rebuilds and a fifth covers VS Code extension activation.

All 13 behavior traces claims →

Testing signals

Testing is Go-native (`go test ./...`, gotest.tools asserts) plus Node tests for the npm package and a bundled esbuild+node:test suite for the extension. The dominant signal is the baseline harness: internal/testrunner runs the ported Strada corpus under tsc/testdata/tests/cases (compiler/conformance/transpile, ~12.4k case files) and diffs outputs against tsc/testdata/baselines/reference, with `hereby baseline-accept` to promote. ~4,360 generated fourslash _test.go files exercise language-service features through an in-process LSP client; tsctests simulate the CLI including watch mode; the API and project/session layers have dedicated session tests. CI runs a large matrix: OS/arch (incl. Windows/Linux/macOS, arm64), race mode, noembed build tag, concurrent test programs, plus lint/format/generate/tidy/smoke jobs.

All 13 testing signals claims →

Risk map

The highest-risk surfaces are process spawning and protocol trust boundaries: the binary can exec arbitrary commands for content mappers (gated by --runExternalCode) and npm installs for ATA, and the --api server exposes the host filesystem (optionally piped through client callbacks) to whoever holds the pipe/stdio. Correctness risk concentrates in the baseline corpus: thousands of accepted diffs vs the JS compiler and an explicit skip list mean behavior parity is approximate, not exact. Platform-specific code (fswatch assembly FFI, per-OS process-alive checks) and panic-prone paths (NewServer panics on missing Cwd; per-request recover in handlers) are fragile spots. Generated files and the dual go.mod workspace create mechanical traps rather than runtime risk.

All 14 risk map claims →

Extension points

Extension happens at well-defined registries. New LSP methods plug into the handlers() map via registerRequestHandler/registerNotificationHandler/registerLanguageService*RequestHandler helpers, with protocol types generated from the LSP meta-model. New API methods add a Method constant plus an unmarshallerFor entry in proto.go and a handler on the session. The compiler is host-driven: vfs.FS, CompilerHost, CheckerPool, and contentmapper.Spawner are all injectable. Diagnostics, enums, AST kinds and localized strings are codegen'd from JSON/Go sources via hereby generate:* tasks. On the product side, tsconfig `contentMappers` is a user-facing plugin model, and the VS Code extension exposes registerContentMappers to other extensions.

All 13 extension points claims →

Contributor handoff

Treat this as a Go repo with a Node-driven build. Read CONTRIBUTING.md first (Go 1.27, Node 24, `npm ci`, hereby commands), then Herebyfile.mjs for task wiring. For compiler changes the spine is cmd/tsc/main.go -> internal/execute/tsc.go -> internal/compiler/program.go; for server work it is internal/lsp/server.go (handlers map) + internal/project/session.go + internal/ls/*. Never edit *_generated.go / *.generated.ts files — change the generator inputs and run `npx hereby generate`. Verify with focused Go tests (`go -C ./tsc test -run 'TestLocal/<name>' ./internal/testrunner`), the baseline-accept workflow, and `npx hereby lint`/`format`/`tidy` before finishing.

Languages

LanguageFilesShare of source
TypeScript1315842%
JavaScript1313342%
Go511916%
JSON185docs/config
Markdown66docs/config
YAML34docs/config

Start reading here

Probable source entrypoint: packages/ — inferred from the directory tree and manifest, not the upstream docs.

Source roots

packages/ (185 files)

Source layout — packages/

PathFiles
packages/typescript/148
packages/vscode-typescript/33
packages/vscode-typescript-nightly/4

Repository structure

Top-level pathFiles
tsc/3697
packages/185
tools/67
.github/31
.devcontainer/1

Docs found: CONTRIBUTING.mdREADME.md

Package

package.json — @typescript/repo v0.0.0, 13 declared dependencies.

@dprint/json@dprint/typescript@jakebailey/dprint-plugin-gofumpt@types/node@unicode/unicode-15.1.0adm-zipchokidardprintdprint-plugin-yamlherebytartinyexec

CI & config entrypoints

Structural health signals

Average score 7.1/10 across 96 analyzed source files; 28 hotspots surfaced.

These are deterministic review leads — size, churn, and structural signals — not proof of a bug in this project.

Recent history