typescript-advanced-types

Implement generics, conditional types, mapped types, and utility types in TypeScript projects.

Updated Apr 14, 2026
One-click install
npx skills add https://github.com/alecanche04-cyber/examenprograma --skill typescript-advanced-types-alecanche04-cyber
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-advanced-types
Source: https://github.com/alecanche04-cyber/examenprograma/tree/main/EXAMEN_PROGRA_2-master/.agents/skills/typescript-advanced-types
Command: npx skills add https://github.com/alecanche04-cyber/examenprograma --skill typescript-advanced-types-alecanche04-cyber

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing type-safe TypeScript code for complex scenarios like API clients, form validation, and state management requires deep knowledge of generics, conditional types, and mapped types, which many developers find difficult to apply correctly. ## Core Features & Use Cases - Advanced Type Patterns: Guidance on generics, conditional types, mapped types, template literal types, and built-in utility types with working code examples. - Real-World Patterns: Ready-to-adapt implementations of type-safe event emitters, API clients, builders, deep readonly/partial types, form validators, and discriminated unions. - Type Inference & Testing: Techniques for the infer keyword, type guards, assertion functions, and compile-time type testing. - 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 implement 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 create a type-safe event emitter in TypeScript?

Define an event map type mapping event names to payload types, then use generics with mapped types so on() and emit() methods infer the correct payload type per event. The compiler then rejects mismatched event names or payloads.

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

Use a conditional type with the infer keyword: 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 argument.

What is the difference between type and interface in TypeScript?

Interfaces are preferred for object shapes because they produce better error messages and support declaration merging. Type aliases are more flexible for unions, conditional types, mapped types, and other complex type computations.

Does TypeScript support deep readonly or deep partial types?

TypeScript has no built-in deep variants, but you can define them recursively with mapped and conditional types that check whether each property is an object, array, or function before transforming it.

Why should I use unknown instead of any in TypeScript?

The unknown type forces explicit type checking or narrowing before a value can be used, while any disables all type checking. Using unknown with type guards preserves compile-time safety without losing flexibility.

When should I avoid complex conditional types in TypeScript?

Avoid deeply nested conditional types when they slow compilation or become unreadable. Prefer simpler types, cache complex computations in named aliases, and limit recursion depth in recursive type definitions.