typescript-advanced-types

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

Updated Aug 11, 2026
One-click install
npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill typescript-advanced-types-duccuong159
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-advanced-types
Source: https://github.com/DucCuong159/Realtime-chatapp/tree/main/.agent/skills/typescript-advanced-types
Command: npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill typescript-advanced-types-duccuong159

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing reusable, type-safe TypeScript code requires mastering advanced type system features like generics, conditional types, and mapped types, which many developers find difficult to apply correctly in real projects. ## Core Features & Use Cases - Advanced Type Patterns: Covers generics with constraints, conditional types with infer, mapped types with key remapping, and template literal types for string manipulation. - Production Patterns: Includes type-safe event emitters, API clients, builder patterns, deep readonly/partial utilities, form validation, and discriminated union state machines. - Type Inference & Testing: Demonstrates type guards, assertion functions, the infer keyword, and compile-time type testing techniques. - Use Case: When building a type-safe API client where request parameters, bodies, and responses must be inferred from an endpoint configuration map, this Skill provides the exact conditional type and inference patterns needed. ## Quick Start Ask the AI to help you build a type-safe event emitter or API client in TypeScript using generics and conditional types.

Frequently Asked Questions about typescript-advanced-types

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

FAQPage Schema
How do I use generics with constraints in TypeScript?

Use the extends keyword on a type parameter to constrain generics, such as function logLength<T extends HasLength>(item: T). This ensures the argument has the required properties while preserving the specific type passed in.

How to create a type-safe event emitter in TypeScript?

Define an event map interface mapping event names to payload types, then use generic methods constrained by keyof the map. The on and emit methods infer the correct payload type from the event name automatically.

What is the difference between conditional types and mapped types?

Conditional types select a type based on a condition using T extends U ? X : Y, while mapped types iterate over an object's keys to transform each property. They are often combined for filtering or remapping object shapes.

When should I use type guards instead of type assertions?

Use type guards with the value is Type syntax when narrowing unknown or union types at runtime, since they perform actual checks. Type assertions with as bypass compiler verification and can hide runtime errors.

What are the limitations of deeply recursive TypeScript types?

Deeply nested conditional or recursive types can slow compilation and hit recursion depth limits. Cache complex type computations, limit recursion depth, and prefer simpler types when the extra precision is unnecessary.