typescript-advanced-types

Implement generics, conditional types, mapped types, and template literal types in TypeScript.

Updated Mar 6, 2026
One-click install
npx skills add https://github.com/ebecerra-developer/ebecerra-web --skill typescript-advanced-types-ebecerra-developer
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: typescript-advanced-types
Source: https://github.com/ebecerra-developer/ebecerra-web/tree/main/.agents/skills/typescript-advanced-types
Command: npx skills add https://github.com/ebecerra-developer/ebecerra-web --skill typescript-advanced-types-ebecerra-developer

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing complex TypeScript type logic without guidance leads to unsafe casts, overuse of any, and brittle type definitions that fail at compile time or runtime. ## Core Features & Use Cases - Advanced Type Patterns: Covers generics, conditional types, mapped types, template literal types, and built-in utility types with working code examples. - Real-World Patterns: Includes type-safe event emitters, API clients, builders, deep readonly/partial types, form validation, and discriminated unions. - Type Inference & Testing: Explains the infer keyword, type guards, assertion functions, and type-level testing techniques. - Use Case: When building a type-safe API client where request bodies, params, and responses must be inferred from an endpoint configuration map, follow the included API client pattern to get full compile-time safety. ## Quick Start Ask the AI to help you design a type-safe event emitter or generic utility type in TypeScript using the patterns from this skill.

Frequently Asked Questions about typescript-advanced-types

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a type-safe event emitter in TypeScript?▼

Define an event map type mapping event names to payload types, then use generics with keyof constraints so on() and emit() only accept valid events with correctly typed data. The compiler rejects mismatched payloads at compile time.

How to extract a function's return type in TypeScript?▼

Use a conditional type with infer: type ReturnType<T> = T extends (...args: any[]) => infer R ? R : never. This extracts the return type R from any function type passed as the generic parameter.

What is the difference between mapped types and conditional types?▼

Mapped types iterate over an existing type's keys to transform properties, like Partial or Readonly. Conditional types select a type based on a condition using extends, enabling logic like extracting types or distributing over unions.

When should I use unknown instead of any in TypeScript?▼

Use unknown for values whose type is not yet known, since it forces type narrowing through guards before use. Unlike any, unknown preserves type safety and prevents accidental unsafe operations on the value.

Why do deeply nested conditional types slow down TypeScript compilation?▼

Each nested conditional forces the compiler to evaluate more type branches, and recursive types multiply this cost exponentially. Cache intermediate results in named type aliases and limit recursion depth to keep compilation fast.