typescript-advanced-types

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

Updated May 14, 2026
One-click install
npx skills add https://github.com/jesusprodriguezUnir/bracketMundial --skill typescript-advanced-types-jesusprodriguezunir
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: typescript-advanced-types
Source: https://github.com/jesusprodriguezUnir/bracketMundial/tree/main/.agents/skills/typescript-advanced-types
Command: npx skills add https://github.com/jesusprodriguezUnir/bracketMundial --skill typescript-advanced-types-jesusprodriguezunir

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing complex TypeScript logic 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 building type-safe applications using TypeScript's advanced type system. ## 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 validators, and discriminated-union state machines. - Type Inference & Testing: Explains type guards, assertion functions, the infer keyword, and type-level testing with assertion helpers. - Use Case: When building a type-safe API client where each endpoint has distinct params, body, and response types, apply the EndpointConfig pattern so invalid calls fail at compile time instead of runtime. ## Quick Start Ask the AI to design a type-safe event emitter or API client in TypeScript using generics and conditional types for your specific interfaces.

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 interface mapping event names to payload types, then use a generic class constrained to that map with mapped types for listener storage. The on and emit methods use keyof generics so each event only accepts its declared payload type.

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

Use conditional types with the infer keyword: T extends (...args: infer P) => infer R captures parameters as P and return type as R. TypeScript also ships built-in ReturnType and Parameters utility types for common cases.

What is the difference between interface and type in TypeScript?▼

Interfaces are best for object shapes because they produce clearer error messages and support declaration merging. Type aliases are more flexible for unions, conditional types, mapped types, and other computed type expressions.

Does TypeScript strict mode affect advanced type patterns?▼

Yes, strict mode enables strictNullChecks and related flags that make generic constraints and discriminated unions behave correctly. The skill recommends enabling all strict compiler options and preferring unknown over any to preserve type safety.

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

Each conditional branch forces the compiler to evaluate type relationships recursively, and deeply nested or recursive types multiply that work exponentially. Mitigate by caching computed types in aliases, limiting recursion depth, and simplifying type expressions where possible.

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

Use type guards with the value is T syntax whenever narrowing unknown or union values at runtime, because they verify the actual value before narrowing. Assertions with as bypass compiler checks and can hide runtime mismatches.