Back to Rules

๐Ÿง  Copilot Rule โ€” TypeScript Type-Safe Code Generation

OfficialPopular
Github copilotTypeScript
copilottypescriptgithub-copilottype-safetycode-generationbest-practices

You are a TypeScript engineer using GitHub Copilot to produce strongly-typed, predictable, and maintainable code for modern applications.

๐ŸŽฏ Steer Copilot Toward Strong Types

  • Describe the type shapes you expect before generating logic
  • Define clear interfaces and contracts to limit Copilot's guesswork
  • Avoid any unless intentionally typed leakage
  • TypeScript is as strong as the types you give it

๐Ÿงฉ Model APIs and Data Structures First

  • Specify request/response types for clarity in suggestions
  • Share data schemas with the team before coding begins
  • Let Copilot help maintain consistency across layers

โš ๏ธ Safe Autocomplete Guardrails

  • Review runtime guarantees, not just type satisfaction
  • Reject hidden as unknown or unsafe casts
  • Validate Copilot doesn't bypass input validation

โœจ Predictable Component Interfaces

  • Encourage simple prop shapes and strict required fields
  • Let Copilot generate overloads only when necessary
  • Avoid prop polymorphism that complicates refactoring

๐Ÿ”„ Refactor With Type Confidence

  • Use Copilot to migrate legacy JS โ†’ TS step-by-step
  • Automate renames using type-driven references
  • Ask Copilot to propose narrowed types for better safety

๐Ÿงช Test-Ready Code Output

  • Prefer pure functions with typed inputs/outputs
  • Maintain mocks for dependent services
  • Make test usage explicit in comments and hints

๐Ÿ” Secure and Stable Type Practices

  • Confirm input types enforce domain rules, not just shapes
  • Block sensitive data leakage through shared types
  • Regularly review type expansions for security scope creep

๐Ÿง  Collaboration Patterns with Copilot

  • Summarize decisions in code comments for future devs
  • Use Copilot to enforce team naming and folder conventions
  • Let Copilot propose documentation updates during refactors

๐Ÿ”‘ TypeScript + Copilot Principles

  • Strong types reduce human errors โ€” tell Copilot to prefer them
  • Consistency matters more than cleverness
  • Architecture lives in the type system
  • Trusted code is code you can safely refactor
View Tool Page