# microsoft/typescript architecture

> Architecture diagram of the GitHub repository microsoft/typescript, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/typescript
- Repository: https://github.com/microsoft/typescript

## Overview

TypeScript is a language compiler and tooling platform: users compile JavaScript/TypeScript projects into JavaScript and receive diagnostics, while editors use its language server for interactive features. The map follows the command-line and language-server entry points, the compiler and language-service stages, and the VS Code client. It also includes the public API clients and the extension’s configuration and middleware capabilities. Some relationships are based on the SOURCE INDEX or README rather than complete source excerpts; those evidence limits are reflected in the edges.

Main entry points: [`packages/vscode-typescript/src/session.ts`](https://github.com/microsoft/typescript/blob/main/packages/vscode-typescript/src/session.ts) (Extension session), [`tsc/internal/compiler/program.go`](https://github.com/microsoft/typescript/blob/main/tsc/internal/compiler/program.go) (Compiler program), [`tsc/cmd/tsc/main.go`](https://github.com/microsoft/typescript/blob/main/tsc/cmd/tsc/main.go) (CLI entrypoint), [`packages/typescript/src/api/async/client.ts`](https://github.com/microsoft/typescript/blob/main/packages/typescript/src/api/async/client.ts) (Async API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entrypoints["User entrypoints"]
  node_cli["CLI entrypoint<br/>[main.go]"]
  node_lspserver["LSP server<br/>[server.go]"]
end

subgraph group_compile["Compilation"]
  node_program["Compiler program<br/>[program.go]"]
  node_incremental["Incremental builds<br/>[program.go]"]
  node_watch["Watch manager<br/>[watchmanager.go]"]
  node_ast["AST scanner<br/>[scanner.ts]"]
  node_checker["Type checker<br/>[services.go]"]
end

subgraph group_editor["Editor services"]
  node_language["Language service<br/>[languageservice.go]"]
end

subgraph group_vscode["VS Code integration"]
  node_extension["Extension session<br/>[session.ts]"]
  node_client["Language client<br/>[client.ts]"]
  node_commands["Editor commands<br/>[commands.ts]"]
  node_middleware["LSP middleware<br/>[lspMiddleware.ts]"]
  node_contentmapper["Content mapping"]
  node_telemetry["Telemetry reporting"]
  node_sdk["SDK selection<br/>[tsdkPackage.ts]"]
end

subgraph group_api["Public API"]
  node_api_async["Async API client<br/>[client.ts]"]
  node_api_sync["Sync API client<br/>[client.ts]"]
  node_api_fs["Filesystem callbacks<br/>[fsCallbacks.ts]"]
  node_api_options["API options<br/>[options.ts]"]
  node_api_proto["API protocol types<br/>[proto.ts]"]
  node_api_server["API server<br/>[server.go]"]
end

node_developer(("Developer"))
node_vscodeuser(("VS Code user"))
node_filesystem[("Project files")]

node_developer -->|"invokes"| node_cli
node_cli -.->|"compiles project"| node_program
node_program -->|"checks types"| node_checker
node_program -.->|"parses source"| node_ast
node_program -.->|"reads project"| node_filesystem
node_cli -.->|"supports incremental builds"| node_incremental
node_incremental -->|"wraps program"| node_program
node_cli -.->|"supports watch mode"| node_watch
node_watch -.->|"watches changes"| node_filesystem
node_developer -.->|"uses API"| node_api_async
node_developer -.->|"uses API"| node_api_sync
node_api_async -->|"resolves executable"| node_api_options
node_api_async -->|"encodes callbacks"| node_api_fs
node_api_async -->|"uses protocol types"| node_api_proto
node_api_sync -->|"reads options"| node_api_options
node_api_sync -->|"configures callbacks"| node_api_fs
node_api_sync -->|"uses protocol types"| node_api_proto
node_cli -->|"starts API mode"| node_api_server
node_vscodeuser -.->|"uses editor"| node_extension
node_extension -->|"starts client"| node_client
node_client -->|"selects executable"| node_sdk
node_client -.->|"connects to server"| node_lspserver
node_lspserver -->|"dispatches language requests"| node_language
node_language -->|"uses compiler program"| node_program
node_language -->|"queries type information"| node_checker
node_extension -->|"registers commands"| node_commands
node_extension -->|"configures middleware"| node_middleware
node_extension -->|"configures mapping"| node_contentmapper
node_extension -->|"configures reporting"| node_telemetry

click node_cli "https://github.com/microsoft/typescript/blob/main/tsc/cmd/tsc/main.go"
click node_lspserver "https://github.com/microsoft/typescript/blob/main/tsc/internal/lsp/server.go"
click node_program "https://github.com/microsoft/typescript/blob/main/tsc/internal/compiler/program.go"
click node_incremental "https://github.com/microsoft/typescript/blob/main/tsc/internal/execute/incremental/program.go"
click node_watch "https://github.com/microsoft/typescript/blob/main/tsc/internal/execute/watchmanager/watchmanager.go"
click node_ast "https://github.com/microsoft/typescript/blob/main/packages/typescript/src/ast/scanner.ts"
click node_language "https://github.com/microsoft/typescript/blob/main/tsc/internal/ls/languageservice.go"
click node_checker "https://github.com/microsoft/typescript/blob/main/tsc/internal/checker/services.go"
click node_extension "https://github.com/microsoft/typescript/blob/main/packages/vscode-typescript/src/session.ts"
click node_client "https://github.com/microsoft/typescript/blob/main/packages/vscode-typescript/src/client.ts"
click node_commands "https://github.com/microsoft/typescript/blob/main/packages/vscode-typescript/src/commands.ts"
click node_middleware "https://github.com/microsoft/typescript/blob/main/packages/vscode-typescript/src/lspMiddleware.ts"
click node_contentmapper "https://github.com/microsoft/typescript/blob/main/packages/vscode-typescript/src/contentMapperContributions.ts"
click node_telemetry "https://github.com/microsoft/typescript/blob/main/packages/vscode-typescript/src/telemetryReporting.ts"
click node_sdk "https://github.com/microsoft/typescript/blob/main/packages/vscode-typescript/src/tsdkPackage.ts"
click node_api_async "https://github.com/microsoft/typescript/blob/main/packages/typescript/src/api/async/client.ts"
click node_api_sync "https://github.com/microsoft/typescript/blob/main/packages/typescript/src/api/sync/client.ts"
click node_api_fs "https://github.com/microsoft/typescript/blob/main/packages/typescript/src/api/fsCallbacks.ts"
click node_api_options "https://github.com/microsoft/typescript/blob/main/packages/typescript/src/api/options.ts"
click node_api_proto "https://github.com/microsoft/typescript/blob/main/packages/typescript/src/api/proto.ts"
click node_api_server "https://github.com/microsoft/typescript/blob/main/tsc/internal/api/server.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_lspserver,node_vscodeuser toneBlue
class node_program,node_incremental,node_watch,node_ast,node_checker,node_filesystem toneAmber
class node_language toneMint
class node_extension,node_client,node_commands,node_middleware,node_contentmapper,node_telemetry,node_sdk toneRose
class node_api_async,node_api_sync,node_api_fs,node_api_options,node_api_proto,node_api_server,node_developer toneIndigo
```

## Components

### User entrypoints

- [CLI entrypoint](https://github.com/microsoft/typescript/blob/main/tsc/cmd/tsc/main.go): `tsc/cmd/tsc/main.go`
- [LSP server](https://github.com/microsoft/typescript/blob/main/tsc/internal/lsp/server.go): `tsc/internal/lsp/server.go`

### Compilation

- [Compiler program](https://github.com/microsoft/typescript/blob/main/tsc/internal/compiler/program.go): `tsc/internal/compiler/program.go`
- [Incremental builds](https://github.com/microsoft/typescript/blob/main/tsc/internal/execute/incremental/program.go): `tsc/internal/execute/incremental/program.go`
- [Watch manager](https://github.com/microsoft/typescript/blob/main/tsc/internal/execute/watchmanager/watchmanager.go): `tsc/internal/execute/watchmanager/watchmanager.go`
- [AST scanner](https://github.com/microsoft/typescript/blob/main/packages/typescript/src/ast/scanner.ts): `packages/typescript/src/ast/scanner.ts`
- [Type checker](https://github.com/microsoft/typescript/blob/main/tsc/internal/checker/services.go): `tsc/internal/checker/services.go`

### Editor services

- [Language service](https://github.com/microsoft/typescript/blob/main/tsc/internal/ls/languageservice.go): `tsc/internal/ls/languageservice.go`

### VS Code integration

- [Extension session](https://github.com/microsoft/typescript/blob/main/packages/vscode-typescript/src/session.ts): `packages/vscode-typescript/src/session.ts`
- [Language client](https://github.com/microsoft/typescript/blob/main/packages/vscode-typescript/src/client.ts): `packages/vscode-typescript/src/client.ts`
- [Editor commands](https://github.com/microsoft/typescript/blob/main/packages/vscode-typescript/src/commands.ts): `packages/vscode-typescript/src/commands.ts`
- [LSP middleware](https://github.com/microsoft/typescript/blob/main/packages/vscode-typescript/src/lspMiddleware.ts): `packages/vscode-typescript/src/lspMiddleware.ts`
- [Content mapping](https://github.com/microsoft/typescript/blob/main/packages/vscode-typescript/src/contentMapperContributions.ts): `packages/vscode-typescript/src/contentMapperContributions.ts`
- [Telemetry reporting](https://github.com/microsoft/typescript/blob/main/packages/vscode-typescript/src/telemetryReporting.ts): `packages/vscode-typescript/src/telemetryReporting.ts`
- [SDK selection](https://github.com/microsoft/typescript/blob/main/packages/vscode-typescript/src/tsdkPackage.ts): `packages/vscode-typescript/src/tsdkPackage.ts`

### Public API

- [Async API client](https://github.com/microsoft/typescript/blob/main/packages/typescript/src/api/async/client.ts): `packages/typescript/src/api/async/client.ts`
- [Sync API client](https://github.com/microsoft/typescript/blob/main/packages/typescript/src/api/sync/client.ts): `packages/typescript/src/api/sync/client.ts`
- [Filesystem callbacks](https://github.com/microsoft/typescript/blob/main/packages/typescript/src/api/fsCallbacks.ts): `packages/typescript/src/api/fsCallbacks.ts`
- [API options](https://github.com/microsoft/typescript/blob/main/packages/typescript/src/api/options.ts): `packages/typescript/src/api/options.ts`
- [API protocol types](https://github.com/microsoft/typescript/blob/main/packages/typescript/src/api/proto.ts): `packages/typescript/src/api/proto.ts`
- [API server](https://github.com/microsoft/typescript/blob/main/tsc/internal/api/server.go): `tsc/internal/api/server.go`

### Other components

- **Developer**
- **VS Code user**
- **Project files**

## Connections

- Developer → CLI entrypoint: invokes (evidence: `tsc/cmd/tsc/main.go`)
- CLI entrypoint → Compiler program: compiles project
- Compiler program → Type checker: checks types (evidence: `tsc/internal/compiler/program.go`)
- Compiler program → AST scanner: parses source
- Compiler program → Project files: reads project
- CLI entrypoint → Incremental builds: supports incremental builds
- Incremental builds → Compiler program: wraps program (evidence: `tsc/internal/execute/incremental/program.go`)
- CLI entrypoint → Watch manager: supports watch mode
- Watch manager → Project files: watches changes
- Developer → Async API client: uses API
- Developer → Sync API client: uses API
- Async API client → API options: resolves executable (evidence: `packages/typescript/src/api/async/client.ts`)
- Async API client → Filesystem callbacks: encodes callbacks (evidence: `packages/typescript/src/api/async/client.ts`)
- Async API client → API protocol types: uses protocol types (evidence: `packages/typescript/src/api/async/client.ts`)
- Sync API client → API options: reads options (evidence: `packages/typescript/src/api/sync/client.ts`)
- Sync API client → Filesystem callbacks: configures callbacks (evidence: `packages/typescript/src/api/sync/client.ts`)
- Sync API client → API protocol types: uses protocol types (evidence: `packages/typescript/src/api/sync/client.ts`)
- CLI entrypoint → API server: starts API mode (evidence: `tsc/cmd/tsc/main.go`)
- VS Code user → Extension session: uses editor
- Extension session → Language client: starts client (evidence: `packages/vscode-typescript/src/session.ts`)
- Language client → SDK selection: selects executable (evidence: `packages/vscode-typescript/src/client.ts`)
- Language client → LSP server: connects to server
- LSP server → Language service: dispatches language requests (evidence: `tsc/internal/lsp/server.go`)
- Language service → Compiler program: uses compiler program (evidence: `tsc/internal/ls/languageservice.go`)
- Language service → Type checker: queries type information (evidence: `tsc/internal/ls/languageservice.go`)
- Extension session → Editor commands: registers commands (evidence: `packages/vscode-typescript/src/session.ts`)
- Extension session → LSP middleware: configures middleware (evidence: `packages/vscode-typescript/src/session.ts`)
- Extension session → Content mapping: configures mapping (evidence: `packages/vscode-typescript/src/session.ts`)
- Extension session → Telemetry reporting: configures reporting (evidence: `packages/vscode-typescript/src/session.ts`)
