mcpField
T
typescript

typescript

github.com/alicoder001Development54 installs
Repository

About typescript

A TypeScript development skill for applying strict typing and consistent coding conventions. It covers configuration, type design, functions, generics, and utility types.

Key features

  1. 01Strict TypeScript configuration
  2. 02Naming conventions
  3. 03Guidance on type vs interface
  4. 04Avoiding any with unknown
  5. 05Utility types and generics

Use cases

  1. 01Setting up strict tsconfig.json options
  2. 02Choosing types for object shapes and unions
  3. 03Typing public functions and generics

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/alicoder001/agent-skills --skill typescript

After installing, type/typescriptin Claude Code to confirm it loaded.

Bundled filesagents/openai.yaml

Details

From the project README

TypeScript Professional

Strict TypeScript patterns for professional development.

Instructions

1. Strict Mode Configuration

Always enable strict mode in tsconfig.json:

{
  "compilerOptions": {
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true
  }
}
2. Naming Conventions
TypeConventionExample
InterfacePascalCase, prefix with I (optional)User, IUserService
TypePascalCaseUserRole, ApiResponse
EnumPascalCaseStatus, Direction
FunctioncamelCasegetUserById, calculateTotal
VariablecamelCaseuserName, isLoading
ConstantUPPER_SNAKE_CASEMAX_RETRY_COUNT, API_URL
3. Type vs Interface
// ✅ Interface for object shapes
interface User {
  id: string;
  name: string;
  email: string;
}

// ✅ Type for unions, intersections, primitives
type Status = 'pending' | 'active' | 'inactive';
type ApiResponse<T> = { data: T; error: null } | { data: null; error: string };
4. Never Use any
// ❌ Bad
function process(data: any) { ... }

// ✅ Good - use unknown and narrow
function process(data: unknown) {
  if (typeof data === 'string') {
    return data.toUpperCase();
  }
}

// ✅ Good - use generics
function process<T>(data: T): T { ... }
5. Utility Types
// Partial - all optional
type PartialUser = Partial<User>;

// Required - all required
type RequiredUser = Required<User>;

// Pick - select specific
type UserName = Pick<User, 'name'>;

// Omit - exclude specific
type UserWithoutId = Omit<User, 'id'>;

// Record - key-value mapping
type UserMap = Record<string, User>;
6. Function Types
// ✅ Explicit return types for public APIs
function getUser(id: string): Promise<User | null> {
  // ...
}

// ✅ Arrow function with types
const add = (a: number, b: number): number => a + b;
7. Generics
// ✅ Constrained generics
function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] {
  return obj[key];
}

// ✅ Default generic types
interface ApiResponse<T = unknown> {
  data: T;
  status: number;
}

References

Comments

Markdown supported