typescript-advanced-types

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

Updated Apr 23, 2026
One-click install
npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill typescript-advanced-types-sanketadlak
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-advanced-types
Source: https://github.com/SanketAdlak/PDMProjectDesign/tree/main/.agents/skills/typescript-advanced-types
Command: npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill typescript-advanced-types-sanketadlak

SYSTEM DOCUMENTATION & REQUIREMENTS

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 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, 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 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, apply the conditional type extraction patterns to enforce correctness at compile time. ## Quick Start Ask the AI to help you implement a type-safe event emitter or generic utility type in TypeScript using the advanced type patterns from this 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 rejects mismatched event names or payloads at compile time.

How to extract return types and parameter types in TypeScript?

Use conditional types with the `infer` keyword, such as `T extends (...args: infer P) => infer R` to capture parameters and return types. 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 `Partial` or `Readonly`. Conditional types select a type based on a condition using `extends`, enabling logic like extracting types from unions or functions.

Should I use interface or type in TypeScript?

Prefer `interface` for object shapes because it produces clearer error messages and supports declaration merging. Use `type` for unions, tuples, conditional types, and other complex type compositions that interfaces cannot express.

Why should I avoid using any in TypeScript?

Using `any` disables type checking entirely, defeating TypeScript's compile-time safety and hiding bugs until runtime. Use `unknown` instead, which forces explicit type narrowing through guards before the value can be used.

When do advanced TypeScript types hurt performance?

Deeply nested conditional types and unbounded recursive types slow compilation significantly. Cache complex type computations, limit recursion depth, and prefer simpler type expressions when they achieve the same safety guarantees.