typescript-advanced-types

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing complex TypeScript code without deep type-system knowledge leads to unsafe any casts, duplicated type definitions, and runtime errors that the compiler could have caught. This Skill provides patterns and reference implementations for TypeScript's advanced type system so you can build type-safe libraries, APIs, and applications. ## Core Features & Use Cases - Advanced Type Patterns: Covers generics with constraints, conditional types with infer, mapped types with key remapping, template literal types, and all built-in utility types. - Production Patterns: Includes ready-to-adapt implementations of typed event emitters, type-safe API clients, builder patterns with compile-time completeness checks, deep readonly/partial types, form validation, and discriminated-union state machines. - Type Inference & Testing: Explains type guards, assertion functions, the infer keyword, and type-level unit testing with assertion helpers. - Use Case: When building a REST API client, use the endpoint-config pattern to get fully typed request parameters, bodies, and responses for every route and HTTP method. ## Quick Start Ask the AI to help you implement a type-safe event emitter or generic utility type in TypeScript using the advanced types 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 mapped types so `on` and `emit` methods infer the correct payload per event. The compiler then rejects mismatched event names or payloads at compile time.

How to extract return types and parameter types from functions in TypeScript?▼

Use conditional types with the `infer` keyword, such as `T extends (...args: infer P) => infer R ? R : never`. TypeScript also ships built-in `ReturnType<T>` and `Parameters<T>` utility types for common cases.

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

Mapped types iterate over an existing type's keys to transform properties, like making them readonly or optional. Conditional types select a type based on a check using `extends`, enabling logic like extracting types from unions or functions.

Does TypeScript strict mode affect advanced type patterns?▼

Yes, strict mode enables strict null checks and stricter inference, which advanced patterns rely on for correctness. The skill recommends enabling all strict compiler options and preferring `unknown` over `any` to preserve type safety.

Why do complex conditional types slow down TypeScript compilation?▼

Deeply nested or recursive conditional types force the compiler to evaluate many type branches, increasing check time. Mitigate this by caching computed types in aliases, limiting recursion depth, and simplifying type logic where possible.

When should I use type guards instead of type assertions?▼

Use type guards (`value is T`) or assertion functions whenever narrowing unknown or union types at runtime, because they verify the value before narrowing. Type assertions (`as T`) skip checks and can hide runtime errors.