typescript-advanced-types

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

Updated Jun 9, 2026
One-click install
npx skills add https://github.com/TOBIASpuchito/Citec --skill typescript-advanced-types-tobiaspuchito
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: typescript-advanced-types
Source: https://github.com/TOBIASpuchito/Citec/tree/main/citec-frontend/.agents/skills/typescript-advanced-types
Command: npx skills add https://github.com/TOBIASpuchito/Citec --skill typescript-advanced-types-tobiaspuchito

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing complex TypeScript type logic without guidance leads to unsafe casts, overuse of any, and missed compile-time guarantees. This Skill provides patterns and worked examples for building type-safe applications using TypeScript's advanced type system. ## Core Features & Use Cases - Advanced Type Patterns: Covers generics, conditional types, mapped types, template literal types, and built-in utility types with runnable examples. - Real-World Implementations: Includes type-safe event emitters, API clients, builders, form validators, deep readonly/partial types, and discriminated union state machines. - Type Inference & Testing: Demonstrates the infer keyword, type guards, assertion functions, and compile-time type assertion tests. - 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 checking. ## Quick Start Ask the AI to help you implement a type-safe event emitter or generic utility type in TypeScript using this skill's patterns.

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 a generic class with mapped types for the listeners record. The `on` and `emit` methods constrain event names with `keyof T` so payloads are checked 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`. TypeScript also ships built-in `ReturnType<T>` and `Parameters<T>` utility types for the same purpose.

What is the difference between interface and type 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 strict mode affect advanced type patterns?▼

Yes, enabling strict mode is recommended because strict null checks and related flags make conditional types and type guards behave correctly. Without it, patterns like NonNullable and discriminated union narrowing lose their safety guarantees.

Why do complex conditional types slow down TypeScript compilation?▼

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

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

Use `unknown` for values whose type is not yet determined, because it forces type narrowing through guards before use. The `any` type disables all checking and defeats the purpose of TypeScript's type safety.