20 typescript rules available
Twenty Copilot rules match typescript. Four are substantive (two TypeScript standards rules, React guidelines and Next.js development); the rest are short tooling prompts such as webpack, ESLint, regex and VS Code extensions. The file below sets strict-typing expectations for Copilot completions and code review on .ts/.tsx files.
GitHub Copilot reads repository-wide custom instructions from .github/copilot-instructions.md and path-specific instructions from .github/instructions/*.instructions.md files with an applyTo glob. Copilot can also use AGENTS.md files, where the nearest file in the directory tree takes precedence. Which file types are honored depends on the surface: VS Code, Visual Studio, JetBrains, Xcode, Eclipse and GitHub.com differ.
.github/instructions/typescript.instructions.mdStarting point, not a tested configuration for your repository. Used for files matching applyTo on surfaces that support path-specific instructions. Review the instructions, adapt the file paths and run your project's existing checks.
--- applyTo: "**/*.ts,**/*.tsx" --- # TypeScript instructions for GitHub Copilot ## Focus for this project - In review, flag new any, as unknown as X and ! assertions and suggest a narrowing alternative. - Flag JSON.parse or response.json() results used without validation. - Suggest discriminated unions instead of optional-field bags for state objects. ## TypeScript conventions - Keep "strict": true. Note that noUncheckedIndexedAccess is a separate flag that strict does not enable; respect whichever setting tsconfig.json has. - Use unknown, not any, for untrusted data and narrow it with type guards or a schema validator before use. - Model variants as discriminated unions and end switch statements with an exhaustive never check. - Do not add non-null assertions (!) or as casts to silence an error; fix the type instead and explain any cast that remains. ## Before you finish - Run npx tsc --noEmit plus the project's lint and test scripts and report the actual output. If you cannot run them, say so and list the exact commands instead of saying they pass. - Summarize which of the rules above affected the change. - When reviewing a pull request, comment only where a change breaks one of these instructions and quote the instruction.
Create your own GitHub Copilot rules for TypeScript and share with the community.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
Instruction support differs by surface: VS Code supports repository-wide, path-specific and AGENTS.md instructions; Visual Studio supports repository-wide and path-specific; JetBrains and Xcode use .github/copilot-instructions.md. GitHub's documentation describes AGENTS.md files stored anywhere in the repository, with the nearest file in the directory tree taking precedence, or alternatively a single CLAUDE.md or GEMINI.md in the root. Support differs by surface; GitHub's IDE page lists AGENTS.md among the instruction types for VS Code.
Documentation checked 2026-11-05: GitHub Docs: Adding repository custom instructionsGitHub Docs: Repository instructions in your IDE
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
You want Copilot code review to flag new any types, non-null assertions and unchecked JSON parsing in pull requests.
Review a diff adding const data = (await res.json()) as Order[];
A comment explaining the cast is unchecked and suggesting a schema or type guard, plus an example of the narrowed version.
Content reviewed 2026-11-05. Confirm instruction activation in your installed client before relying on it.
Copilot instructions for React 19 TypeScript components that forward native props, use effects only for synchronization and are tested by role.