Copilot instructions
.github/copilot-instructions.mdCopilot instructions
Quality
88/100
Scores the file, not the repository.Length
1,752 words
45 headings · 21 code blocksRepository
110k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# 🚨 CRITICAL: This Repository Is in Maintenance Mode 🚨23**You MUST read and follow these instructions before taking any coding action in this repository.**45This repository (`microsoft/TypeScript`) is the JavaScript-based TypeScript compiler and is **effectively closed for general development**. TypeScript 6.0 is the **last JavaScript-based release**. Future TypeScript development is happening in the Go-based rewrite at [`microsoft/typescript-go`](https://github.com/microsoft/typescript-go).67See [issue #62963](https://github.com/microsoft/TypeScript/issues/62963) and the [TypeScript 7.0 progress blog post](https://devblogs.microsoft.com/typescript/progress-on-typescript-7-december-2025/) for full details.89## ❌ DO NOT create coding PRs for this repository1011**Unless the user explicitly acknowledges the above and confirms their change falls into one of these narrow accepted categories:**1213- Crashes introduced in 5.9 or 6.0 that **also repro in 7.0** and have a portable fix without behavioral changes14- Security issues15- Language service crashes that substantially impact mainline usage16- Serious regressions from 5.9 that impact a large proportion of users17- Non-disruptive `lib.d.ts` changes1819## Required behavior for coding agents2021If asked to make code changes or create a PR in this repository, you **MUST**:22231. Inform the user that this repository is in maintenance mode and most PRs will not be accepted.242. Ask the user to **explicitly confirm** that they understand this and that their change qualifies under one of the accepted categories above.253. **Refuse to proceed** until that acknowledgement is given.264. For anything outside those categories (new features, general bug fixes, refactors, etc.), direct the user to [`microsoft/typescript-go`](https://github.com/microsoft/typescript-go) instead.2728---2930# Guide for Copilot3132This document provides a concise guide for writing TypeScript fourslash tests and compiler tests, along with build instructions.3334## Build Instructions Summary3536### Setup371. Install Node.js (current or LTS)382. Clone the repository: `git clone --depth=1 https://github.com/microsoft/TypeScript`393. Install dependencies: `npm ci`4041### Common Build Tasks42```bash43npx hereby local # Build the compiler into built/local44npx hereby clean # Delete the built compiler45npx hereby tests # Build the test infrastructure46npx hereby runtests # Run all tests47npx hereby runtests-parallel # Run tests in parallel 🚨 MANDATORY BEFORE FINISHING!48npx hereby runtests --runner=fourslash # Run only fourslash tests49npx hereby runtests --runner=compiler # Run only compiler tests50npx hereby runtests --tests=<testPath> # Run specific test51npx hereby baseline-accept # Accept new test baselines52npx hereby lint # Run eslint 🚨 MANDATORY BEFORE FINISHING!53npx hereby format # Run code formatting 🚨 MANDATORY BEFORE FINISHING!54```5556## Fourslash Test Syntax Guide5758Fourslash tests are interactive TypeScript language service tests. They validate IDE features like completions, quick info, navigation, and refactoring.5960### Basic Structure61```typescript62/// <reference path='fourslash.ts'/>6364////code goes here with /*markers*/6566// Test assertions go here67```6869### Key Syntax Elements7071#### 1. Source Code Definition72Use `////` to define source code lines:73```typescript74////function foo(x: number) {75//// return x + 1;76////}77////let result = foo(/*marker*/42);78```7980#### 2. Markers for Positioning81Use `/**/` for anonymous markers or `/*name*/` for named markers:82```typescript83////let x = /*1*/someValue;84////let y = /*cursor*/anotherValue;85```8687#### 3. Multi-file Tests88Use `// @Filename:` to define multiple files:89```typescript90// @Filename: /a.ts91////export const value = 42;9293// @Filename: /b.ts94////import { value } from './a';95////console.log(/*marker*/value);96```9798#### 4. Ranges99Use `[|text|]` to define text ranges:100```typescript101////function test() {102//// [|return 42;|]103////}104```105106### Common API Patterns107108#### Navigation & Positioning109```typescript110goTo.marker("markerName"); // Navigate to marker111goTo.marker(); // Navigate to anonymous marker /**/112```113114#### Verification (Prefer these over baselines)115```typescript116verify.currentLineContentIs("expected content");117verify.completions({ includes: "itemName" });118verify.completions({ excludes: "itemName" });119verify.quickInfoIs("expected info");120verify.codeFix({121 description: "Fix description",122 newFileContent: "expected content after fix"123});124```125126#### Completions Testing127```typescript128verify.completions({129 marker: "1",130 includes: { name: "foo", source: "/a", hasAction: true },131 isNewIdentifierLocation: true,132 preferences: { includeCompletionsForModuleExports: true }133});134```135136#### Code Fixes Testing137```typescript138verify.codeFix({139 description: "Add missing property",140 index: 0,141 newFileContent: `class C {142 property: string;143 method() { this.property = "value"; }144}`145});146```147148#### Formatting149```typescript150format.document();151verify.currentLineContentIs("formatted content");152```153154### Simple Example155```typescript156/// <reference path='fourslash.ts'/>157158////interface User {159//// name: string;160////}161////162////const user: User = {163//// /*completion*/164////};165166verify.completions({167 marker: "completion",168 includes: { name: "name", sortText: "0" }169});170```171172## Compiler Test Syntax Guide173174Compiler tests validate TypeScript compilation behavior, type checking, and error reporting.175176### Basic Structure177- Simple `.ts` files in `tests/cases/compiler/`178- Use comments to indicate expected behavior179- No special test harness - just TypeScript code180181### Compiler Directives182Use `// @directive: value` for compiler options:183```typescript184// @strict: true185// @target: ES2015186// @lib: ES2015,DOM187188let x: string = 42; // Error expected189```190191### Common Directives192```typescript193// @strict: true/false194// @noImplicitAny: true/false195// @target: ES5/ES2015/ES2020/ESNext196// @module: commonjs/amd/es6/esnext197// @lib: ES5,DOM/ES2015/ES2020198// @declaration: true/false199// @skipLibCheck: true/false200```201202### Multi-file Tests203```typescript204// @Filename: helper.ts205export function helper(x: number): string {206 return x.toString();207}208209// @Filename: main.ts210import { helper } from "./helper";211const result = helper(42);212```213214### Error Expectations215Use comments to document expected behavior:216```typescript217abstract class Base {218 abstract method(): void;219}220221class Derived extends Base {222 // Missing implementation - should error223}224225new Base(); // Should error - cannot instantiate abstract class226```227228### Type Testing Patterns229```typescript230// Test type inference231let inferred = [1, 2, 3]; // Should infer number[]232233// Test type compatibility234type A = { x: number };235type B = { x: number; y: string };236let a: A = { x: 1 };237let b: B = { x: 1, y: "hello" };238a = b; // Should work - B is assignable to A239b = a; // Should error - A missing property y240```241242### Simple Example243```typescript244// Test that optional properties work correctly245interface Config {246 required: string;247 optional?: number;248}249250const config1: Config = { required: "test" }; // Should work251const config2: Config = { required: "test", optional: 42 }; // Should work252const config3: Config = { optional: 42 }; // Should error - missing required253```254255## Test Writing Best Practices256257### For Fourslash Tests2581. **Prefer validation over baselines** - Use `verify.currentLineContentIs()` instead of `verify.baseline*()`2592. **Use simple, focused examples** - Test one feature at a time2603. **Name markers clearly** - Use descriptive marker names like `/*completion*/`2614. **Test the simplest form first** - Start with basic cases before complex scenarios262263### For Compiler Tests2641. **Use clear file names** - Name tests after the feature being tested2652. **Add explanatory comments** - Document expected behavior with comments2663. **Test error cases** - Include both valid and invalid code examples2674. **Keep tests focused** - One primary feature per test file268269### General Guidelines2701. **Make tests deterministic** - Avoid random or environment-dependent behavior2712. **Use realistic examples** - Test scenarios developers actually encounter2723. **Start simple** - Begin with the most basic case of a feature2734. **Test edge cases** - Include boundary conditions and error scenarios274275## Running Specific Tests276277```bash278# Run a specific fourslash test279npx hereby runtests --tests=tests/cases/fourslash/completionForObjectProperty.ts280281# Run a specific compiler test282npx hereby runtests --tests=tests/cases/compiler/abstractClassUnionInstantiation.ts283284# Run tests matching a pattern285npx hereby runtests --tests=tests/cases/fourslash/completion*.ts286```287288## Important Guidelines289290### 🚨 CRITICAL: Before Finishing Your Work 🚨291292**THESE STEPS ARE MANDATORY BEFORE COMMITTING/PUSHING ANY CHANGES:**2932941. **MUST RUN:** `npx hereby runtests-parallel` (even though it takes 10-15 minutes)2952. **MUST RUN:** `npx hereby lint` and fix ALL lint issues2963. **MUST RUN:** `npx hereby format` as the final step297298**❌ PRs that fail these checks will be rejected without review.**299300### Keeping Things Tidy301302- You can assume lint, tests, and formatting are clean on a fresh clone303- Only run these verification steps AFTER making changes to code304- Run `npx hereby lint` and fix ALL issues after making changes305- Run `npx hereby format` as your final step after making changes306307### Test Locations308309- Only add testcases in `tests/cases/compiler` or `tests/cases/fourslash`310- Filenames in `tests/cases/compiler` must always end with `.ts`, not `.d.ts`311- Do not write direct unit tests as they are almost never the correct test format for our repo312313### Performance Expectations314315- Running a set of tests may take up to 4 minutes316- A full test run may take up to 15 minutes317318### Working with Issues319320- Maintainer comments in the issue should generally take priority over OP's comments321- Maintainers might give you hints on where to start. They are not always right, but a good place to start322323### Debugging Tips324325printf debugging is going to be very useful as you are figuring things out.326To do this, use `console.log`, but you'll need to `ts-ignore` it.327Write something like this:328```ts,diff329function checkSomething(n: Node) {330 doSomething(n);331+ // @ts-ignore DEBUG CODE ONLY, REMOVE ME WHEN DONE332+ console.log(`Got node with pos = ${n.pos}`);333 doSomethingElse(n);334}335```336We have a lot of enums so you might want to print back their symbolic name, to do this, index back into the name of the enum337```ts338 // @ts-ignore DEBUG CODE ONLY, REMOVE ME WHEN DONE339 console.log(`Got node with kind = ${SyntaxKind[n.kind]}`);340```341342## Recommended Workflow343344When fixing bugs or implementing features, follow this workflow:3453461. **Make a testcase that demonstrates the behavior**347 - Run it (by itself) and review the baselines it generates to ensure it demonstrates the bug348 - Add the test and its baselines in one commit3493502. **Fix the bug by changing code as appropriate**351 - Put this fix in another commit3523533. **Run the test you wrote again**354 - Ensure the baselines change in a way that demonstrates that the bug is fixed355 - Put this baseline diff in its own commit3563574. **Add more testing**358 - Once you've got the basics figured out, enhance your test to cover edge cases and other variations359 - Run the test again and commit the baseline diff along with the test edit3603615. **🚨 MANDATORY: Run all other tests to ensure you didn't break anything**362 - **REQUIRED:** Run `npx hereby runtests-parallel` and wait for it to finish (10-15 minutes is normal!)363 - **THIS STEP CANNOT BE SKIPPED** - patience is essential!364 - Some collateral baseline changes are normal, but review for correctness365 - Put these diffs in another commit3663676. **🚨 MANDATORY: Lint and format your changes**368 - **REQUIRED:** Run `npx hereby lint` and fix ALL issues369 - **REQUIRED:** Run `npx hereby format` before you're done370 - **YOU CANNOT FINISH WITHOUT THESE STEPS**371 - Double-check your line endings. Source files in this repo typically use CRLF line endings. Fix all line endings to be consistent before you wrap up372
Also in microsoft/TypeScript
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| microsoft/TypeScriptAGENTS.md · 110k | AGENTS.md | gitdo-not | 46/100 | 3 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| chihebnabil/lovable-boilerplate.github/instructions/global.instructions.md · 63 | Copilot instructions | buildlint-formatstylearch+4 | 100/100 | 3 days ago | |
| louislam/uptime-kuma.github/copilot-instructions.md · 90k | Copilot instructions | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.github/copilot-instructions.md · 17 | Copilot instructions | setupbuildtestlint-format+7 | 100/100 | 3 days ago | |
| JCodesMore/ai-website-cloner-template.github/copilot-instructions.md · 31k | Copilot instructions | buildlint-formatstylearch+3 | 97/100 | 2 days ago | |
| bagisto/bagisto.github/copilot-instructions.md · 28k | Copilot instructions | setupbuildteststyle+5 | 97/100 | 3 days ago | |
| darkmatter/nixmac.github/copilot-instructions.md · 24 | Copilot instructions | setupbuildtestlint-format+8 | 96/100 | 3 days ago | |
| nerolis-lab/nerolis-lab.github/copilot-instructions.md · 32 | Copilot instructions | setupbuildtestlint-format+11 | 96/100 | 3 days ago | |
| thangaram611/second-brain.github/copilot-instructions.md · 0 | Copilot instructions | setupteststylearch+4 | 96/100 | 3 days ago |
