营销与写作

typescript

gentleman-programming/gentleman-skills

TypeScript strict patterns and best practices. Trigger: When writing TypeScript code - types, interfaces, generics.

  • 496 次安装
  • 661 星标
  • 收录于

安装命令

npx skills add https://github.com/gentleman-programming/gentleman-skills --skill typescript

SKILL.md

Const Types Pattern (REQUIRED)

// ✅ ALWAYS: Create const object first, then extract type
const STATUS = {
  ACTIVE: "active",
  INACTIVE: "inactive",
  PENDING: "pending",
} as const;

type Status = (typeof STATUS)[keyof typeof STATUS];

// ❌ NEVER: Direct union types
type Status = "active" | "inactive" | "pending";

Why? Single source of truth, runtime values, autocomplete, easier refactoring.

Flat Interfaces (REQUIRED)