typescript-advanced-types

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

1|Updated Aug 17, 2025
One-click install
npx skills add https://github.com/ratnesh-maurya/mdconverter --skill typescript-advanced-types-ratnesh-maurya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-advanced-types
Source: https://github.com/ratnesh-maurya/mdconverter/tree/main/.claude/skills/typescript-advanced-types
Command: npx skills add https://github.com/ratnesh-maurya/mdconverter --skill typescript-advanced-types-ratnesh-maurya

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing type-safe TypeScript code for libraries, API clients, and form validation requires deep knowledge of generics, conditional types, and mapped types, which many developers struggle to apply correctly. ## Core Features & Use Cases - Advanced Type Patterns: Guidance on generics, conditional types, mapped types, template literal types, and utility types with working code examples. - Production Patterns: Ready-to-use implementations for type-safe event emitters, API clients, builders, deep readonly/partial types, form validators, and discriminated unions. - Type Inference Techniques: Coverage of the infer keyword, type guards, assertion functions, and type testing helpers. - Use Case: When building a type-safe API client where request bodies 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.

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 use keyof constraints so callbacks receive correctly typed data for each event.

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. TypeScript also ships built-in ReturnType and Parameters utility types that extract these from any function type.

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 support deep readonly and deep partial types?

TypeScript has no built-in deep variants, but you can define recursive mapped types that check whether each property is an object and reapply the transformation. The skill provides working DeepReadonly and DeepPartial implementations.

Why should I avoid using any in TypeScript advanced types?

Using any disables type checking and defeats type safety, letting invalid values pass silently. Prefer unknown with type guards or assertion functions so the compiler still verifies types before use.

When should I not use complex conditional types in TypeScript?

Avoid deeply nested conditional types when they slow compilation or hurt readability. Prefer simpler types, cache complex computations, and limit recursion depth to keep build times reasonable.