typescript-patterns

Solid

TypeScript type system patterns, generics, utility types, and strict mode best practices. Use when writing or reviewing TypeScript code.

AI & Automation 30 stars 9 forks Updated 5 days ago MIT

Install

View on GitHub

Quality Score: 82/100

Stars 20%
50
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# TypeScript Patterns ## Core Rules - Strict mode always (`"strict": true`) - No `any` — use `unknown` for dynamic values - Explicit return types on all functions - `const` over `let`, never `var` ## Type Definitions ### Interfaces vs Types ```typescript // ✅ Interface for objects/classes (extensible) interface User { id: string email: string name: string } // ✅ Type for unions, primitives, computed type Status = 'active' | 'inactive' | 'pending' type UserOrAdmin = User | Admin type ReadonlyUser = Readonly<User> ``` ### Generics ```typescript // ✅ Reusable generic types type ApiResponse<T> = { data: T error: string | null status: number } type PaginatedResponse<T> = { items: T[] total: number page: number limit: number } // ✅ Generic functions const findById = <T extends { id: string }>(items: T[], id: string): T | undefined => items.find(item => item.id === id) ``` ## Utility Types ```typescript // Pick specific fields type UserPreview = Pick<User, 'id' | 'name'> // Omit sensitive fields type PublicUser = Omit<User, 'password' | 'salt'> // Make all optional (for partial updates) type UpdateUserDto = Partial<User> // Make all required type RequiredUser = Required<User> // Make all readonly type FrozenUser = Readonly<User> // Extract from union type ActiveStatus = Extract<Status, 'active' | 'pending'> // Record type type UserMap = Record<string, User> ``` ## Discriminated Unions ```typescript // ✅ Type-safe error handling type Result<T...

Details

Author
sabahattink
Repository
sabahattink/antigravity-fullstack-hq
Created
8 months ago
Last Updated
5 days ago
Language
PowerShell
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category