typescript

TypeScript Professional

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "typescript" with this command: npx skills add alicoder001/agent-skills/alicoder001-agent-skills-typescript

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 } }

  1. Naming Conventions

Type Convention Example

Interface PascalCase, prefix with I (optional) User , IUserService

Type PascalCase UserRole , ApiResponse

Enum PascalCase Status , Direction

Function camelCase getUserById , calculateTotal

Variable camelCase userName , isLoading

Constant UPPER_SNAKE_CASE MAX_RETRY_COUNT , API_URL

  1. 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 };

  1. 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 { ... }

  1. 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>;

  1. 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;

  1. 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

  • TypeScript Handbook

  • TypeScript Deep Dive

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

solid

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

reasoning

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

find-skills

No summary provided by upstream source.

Repository SourceNeeds Review