Skip to content

Build a TypeScript-like language ​

Build one small language step by step: first recognize declarations, then add expressions, modules, diagnostics, references, type rules, and function inference. Start with visible mechanisms, then replace local implementations with reusable standard-library operations. Each chapter identifies the files to create or replace.

This course is a teaching subset, not the TypeScript specification. The structural data and backend chapters are explicit variants: the current repository does not combine every demonstrated feature into one complete TypeScript compiler.

ChapterWhat it addsRunnable repository checkpoint
1. Syntax and projectCaptures, repetition, trivia, AST and yl.json01-getting-started
2. Modules and expressionsImports, reusable keyword boundaries, recursive addition03-mini-js
3. DiagnosticsChecks beside grammar and intentional errors02-constraints
4. ReferencesLocal query-based scope/name operations07-declarative-queries, then 06-references
5. TypesLanguage-owned types, propagation, restrictions08-mini-typescript
6. FunctionsFunction signatures and independent call inference08-mini-typescript, 09-type-instantiation, 10-declarative-functions
7. Compound dataInterface/list/tuple policies and explicit generic arguments11-compound-types, 12-diagnostic-origins
8. EditorContextual token roles and example previews04-ide-metadata; all projects
9. Host backendsInterpret, transpile, and emit Wasm from checked syntax14-backend-hooks

Run shell commands from your project directory unless a chapter explicitly says repository root. Install the CLI using installation. The snippets marked with a filename are complete files. Later chapters replace only the named files; other files remain. All such files and their checks are executed by npm run docs:check-course in repository validation.

The numbered repository examples are checkpoints and focused companions, not nine copies of the same project. 05-tuple-access and 13-formatting are supporting exercises; both retain their common runners.

Next: Create the project.

Declarative languages. Reusable tools.