microsoft/typescript/compiler-and-fourslash-tests
Claude Code and agent skill by microsoft/typescript
- vendor
Checking that the SKILL.md file is still in the repository.
How to write, run, and debug compiler tests and fourslash (LSP) tests in the TypeScript repository. Covers test file formats, directives, markers, baseline management, and the fourslash verification API.
Install
npx vskill@latest install microsoft/typescript/compiler-and-fourslash-testsSKILL.md
Writing, Running, and Debugging Compiler Tests and Fourslash Tests
This guide covers the complete testing workflow for the TypeScript repository, including compiler tests (type-checking, emit, diagnostics) and fourslash tests (language server features like completions, hover, go-to-definition).
1. Compiler Tests
Compiler tests validate the TypeScript compiler's behavior: diagnostics, JavaScript emit, source maps, type/symbol baselines, and more. Each test is a .ts or .tsx file that the test runner compiles, then compares output against stored baselines.
1.1 Where Test Files Live
| Path | Purpose | |
|---|---|---|
tsc/testdata/tests/cases/compiler/ | Regression tests | |
tsc/testdata/tests/cases/conformance/ | Conformance tests |
1.2 Writing a New Compiler Test
A compiler test is just a .ts or .tsx file — no Go code needed. Place it in tsc/testdata/tests/cases/compiler/ for regression tests or tsc/testdata/tests/cases/conformance/<subdir>/ for conformance tests.
Simple single-file test
Using compiler option directives
Set compiler options with // @option: value comment directives at the top of the file:
Multi-file test
Use // @filename: directives to define multiple files in one test:
For readability, make sure to add an extra line between the contents of a file and the next // @filename directive (as we did above).
Generating test variations
Options can specify multiple comma-separated values to generate separate sub-test configurations:
This generates a sub-test for each combination, with names like myTest.ts (target=es2015,module=commonjs,strict=true).
Note: // @lib: is not variant — commas add additional lib files rather than creating separate test configurations:
Symlink tests
Use // @symlink: to create symlinks in the virtual filesystem:
Other directives
// @currentDirectory: /custom/path— Set the working directory// @noImplicitReferences— Don't auto-include referenced files
1.3 Running Compiler Tests
Via hereby (recommended)
Always use npx hereby test to run tests. It ensures a clean state by clearing stale baselines before running, so results are always trustworthy. Trust the results — if hereby test passes, the tests pass.
It's generally best to run all tests — the full suite is very quick and will find issues you didn't realize you were introducing:
If a test fails, the output will include the full test name and package, which you can use to re-run it directly with go test for debugging (see below).
Via Go directly (for print-debugging a single test)
Use go test directly only when you need verbose output for a specific test to debug with print statements. The test output from hereby test will tell you the exact package and test name to use:
The test entry points are:
TestLocal— runs tests fromtestdata/tests/cases/(bothcompiler/andconformance/)
What happens during a test run
For each test file, the runner:
- Parses directives (
// @option:,// @filename:, etc.) - Generates configurations for each option variation
- For each configuration, runs these parallel sub-tests:
error— Verifies diagnostics against.errors.txtbaselineoutput— Verifies JavaScript emit against.jsbaselinesourcemap— Verifies source map outputsourcemap record— Verifies source map recordunion ordering— Validates AST union type orderingsource file parent pointers— Validates AST structure integrity
1.4 Baseline System
Baselines are the expected output files that test results are compared against.
| Directory | Purpose | |
|---|---|---|
tsc/testdata/baselines/reference/ | Golden/expected baselines (committed to repo) | |
tsc/testdata/baselines/local/ | Generated during test runs (not committed) |
Baseline file types
| Extension | Content | |
|---|---|---|
.errors.txt | Diagnostic error messages | |
.js | Emitted JavaScript | |
.d.ts | Declaration output | |
.symbols | Symbol information | |
.types | Type information | |
.sourcemap.txt | Source map output | |
.trace.json | Trace output |
Viewing baseline diffs
Accepting baselines
Important: Only accept baselines immediately after a successful npx hereby test run. The hereby test command clears stale baselines before running, so accepting after it guarantees you're only accepting baselines from the current test run. If you accept without running hereby test first, you risk accepting old/stale baselines from previous runs.
The baseline-accept task:
- Copies all files from
local/toreference/(excluding.deletefiles) - Deletes reference files that have corresponding
.deletemarkers inlocal/
2. Fourslash Tests
Fourslash tests validate language server (LSP) features: completions, hover/quick info, go-to-definition, find references, rename, code fixes, formatting, and more. They're Go test files that set up TypeScript source with position markers, then verify LSP responses.
2.1 Where Test Files Live
| Path | Purpose | |
|---|---|---|
tsc/internal/fourslash/tests/*.go | Hand-written tests | |
tsc/internal/fourslash/tests/manual/*.go | Existing migrated tests | |
tsc/internal/fourslash/tests/util/ | Shared test constants |
New fourslash tests should be hand-written. Do not create or regenerate an upstream-generated fourslash suite.
2.2 Writing a New Fourslash Test
Create a Go test file in tsc/internal/fourslash/tests/. The file uses the fourslash_test package.
Minimal template
Real-world example: Quick Info
Real-world example: Editing and Completions
Marker syntax
Markers define cursor positions and text ranges in the test content:
| Syntax | Description | Example | |||||
|---|---|---|---|---|---|---|---|
/*name*/ | Named position marker | var x/*pos*/ = 1; | |||||
/*1*/, /*2*/ | Numbered markers | foo(/*1*/, /*2*/) | |||||
| `[ | text | ]` | Range marker (selects text) | `[ | let x: number | ]` |
Multi-file tests
Use // @Filename: (capital F) to define multiple files:
Setting compiler options
Embed a tsconfig.json file or use directive comments:
Content mapper tests
When writing a test for a content-mapped file, include a comment that shows the virtual TS output of the test content mapper implementation, and a description or diagram of the mapping spans.
2.3 Verification Methods (Common API)
The fourslash.FourslashTest type (variable f) provides these verification methods:
Quick Info / Hover
Completions
Import the test utilities for shared constants:
Navigation
References and Rename
Diagnostics
Signature Help
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 29 Sep 2026.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/compiler-and-fourslash-tests/SKILL.md
Popularity
- Repository stars
- 111,273
- Repository forks
- 15,378
- 7-day trend score
- 58
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 17 Oct 2026, 29 days ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/microsoft/typescript/compiler-and-fourslash-tests)