typescript-expert

ljchg12-hue's avatarfrom ljchg12-hue

Expert TypeScript development with strict typing, generics, advanced patterns, and best practices

⭐0stars🔀0forks📁View on GitHub🕐Updated Dec 30, 2025

When & Why to Use This Skill

This Claude skill provides expert-level TypeScript development guidance, specializing in strict type safety, advanced generic patterns, and scalable architectural practices. It empowers developers to eliminate runtime errors and improve code maintainability through sophisticated type modeling, custom utility types, and optimized compiler configurations following modern industry standards.

Use Cases

  • Architecting Type-Safe API Clients: Design robust interfaces and generic request handlers that ensure end-to-end type safety and predictable data flow between services.
  • Refactoring Legacy Codebases: Systematically upgrade loosely typed JavaScript or TypeScript projects to strict mode, replacing 'any' types with precise unions, intersections, and branded types.
  • Implementing Advanced Design Patterns: Leverage discriminated unions, template literal types, and conditional types to build complex state machines and type-safe builder patterns.
  • Compiler and Environment Optimization: Configure tsconfig.json with maximum strictness and best practices to catch potential bugs at compile-time and improve developer productivity.
nametypescript-expert
descriptionExpert TypeScript development with strict typing, generics, advanced patterns, and best practices
version1.0.0
authorUSER
tags[typescript, types, generics, strict, nodejs]

TypeScript Expert

Purpose

Provide expert TypeScript guidance including strict typing, advanced type patterns, generics, and modern JavaScript features.

Activation Keywords

  • typescript, ts, types, typing
  • generics, inference, narrowing
  • strict mode, type safety
  • interfaces, type aliases

Core Capabilities

1. Type System Mastery

  • Strict mode configuration
  • Union and intersection types
  • Literal types
  • Template literal types
  • Conditional types
  • Mapped types

2. Generics

  • Generic functions
  • Generic classes
  • Constraints
  • Default type parameters
  • Variance annotations

3. Advanced Patterns

  • Type guards
  • Discriminated unions
  • Branded types
  • Module augmentation
  • Declaration merging

4. Utility Types

  • Partial, Required, Pick, Omit
  • Record, Extract, Exclude
  • ReturnType, Parameters
  • Custom utility types

5. Best Practices

  • Avoid any at all costs
  • Prefer unknown over any
  • Use const assertions
  • Leverage type inference
  • Document complex types

Instructions

When activated:

  1. Configuration Check

    • Verify tsconfig.json settings
    • Enable strict mode
    • Check target version
  2. Type Design

    • Design types before implementation
    • Use interfaces for objects
    • Use type aliases for unions
  3. Implementation

    • Zero any tolerance
    • Explicit return types
    • Proper null handling
    • Use type guards

Code Examples

Strict Configuration

{
  "compilerOptions": {
    "strict": true,
    "noUncheckedIndexedAccess": true,
    "exactOptionalPropertyTypes": true
  }
}

Advanced Types

// Branded types for type safety
type UserId = string & { readonly brand: unique symbol };
type OrderId = string & { readonly brand: unique symbol };

// Type-safe builder pattern
type Builder<T> = {
  [K in keyof T]-?: (value: T[K]) => Builder<T>;
} & { build(): T };

// Conditional type utility
type NonNullableDeep<T> = T extends object
  ? { [K in keyof T]: NonNullableDeep<NonNullable<T[K]>> }
  : NonNullable<T>;

Example Usage

User: "Create a type-safe API client"

TypeScript Expert Response:
1. Define API response types
2. Create generic request function
3. Implement type-safe endpoints
4. Add error type handling
5. Use branded types for IDs