# Typescript Advanced Types

> Use when implementing advanced TypeScript type patterns.

- Skill: `loopyluci/typescript-advanced-types` (Agent Skill)
- Install (CLI): `npx skillmds@latest add loopyluci/typescript-advanced-types`
- Raw SKILL.md: https://api.skillmd.com/api/skills/loopyluci/typescript-advanced-types/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- License: MIT
- Author: LoopyLuci (https://skillmd.com/u/loopyluci)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/loopyluci/typescript-advanced-types

---


# Advanced TypeScript Types

Implementing advanced TypeScript type patterns — from conditional and mapped types through template literals, infer, and type-level programming.

## When to Use

- Building type-safe TypeScript libraries
- Implementing complex type transformations
- Generic utility types
- Type-level validation and parsing

## TypeScript Type Patterns

```typescript
// Conditional types with infer
type UnpackPromise<T> = T extends Promise<infer U> ? U : T;
type Result = UnpackPromise<Promise<string>>; // string

// Mapped types with key remapping
type Getters<T> = {
  [K in keyof T as `get${Capitalize<string & K>}`]: () => T[K]
};

// Template literal types
type EventName<T extends string> = `on${Capitalize<T>}`;
type ClickEvent = EventName<'click'>; // 'onClick'

// Discriminated union pattern
type ApiResult<T> = 
  | { status: 'success'; data: T }
  | { status: 'error'; error: string }
  | { status: 'loading' };
```

## Verification Checklist

- [ ] Conditional types with infer for unwrapping
- [ ] Mapped types with key remapping and filtering
- [ ] Template literal types for string manipulation
- [ ] Recursive type aliases
- [ ] Discriminated unions for state modeling
- [ ] satisfies operator for type validation (TS 4.9+)

