typescript-advanced-types

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

Updated Apr 5, 2026
One-click install
npx skills add https://github.com/RobinMillford/GopherNotebook --skill typescript-advanced-types-robinmillford
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-advanced-types
Source: https://github.com/RobinMillford/GopherNotebook/tree/main/.claude/skills/typescript-advanced-types
Command: npx skills add https://github.com/RobinMillford/GopherNotebook --skill typescript-advanced-types-robinmillford

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

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 find difficult to apply correctly. ## Core Features & Use Cases - Advanced Type Patterns: Provides working examples of generics, conditional types, mapped types, template literal types, and utility types. - Real-World Patterns: Includes implementations of type-safe event emitters, API clients, builders, deep readonly/partial types, form validators, and discriminated unions. - Type Inference Techniques: Covers the infer keyword, type guards, assertion functions, and type-level testing. - Use Case: When building a type-safe API client where request parameters and response types are inferred from an endpoint configuration map, use this Skill to design the conditional types and generic method signatures. ## Quick Start Use the typescript-advanced-types skill to help me build a type-safe event emitter with typed payloads for each event name.

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 keyof constraints so on() and emit() enforce the correct payload type per event. The Skill provides a complete TypedEventEmitter implementation using mapped types over the event map.

How to extract a function's return type in TypeScript?

Use a conditional type with the infer keyword: type ReturnType<T> = T extends (...args: any[]) => infer R ? R : never. This extracts the return type R from any function type passed as the generic parameter.

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

Mapped types iterate over an existing type's properties to transform them, such as making all properties readonly or optional. Conditional types select a type based on a condition using the extends keyword, enabling type-level logic like extracting or filtering types.

When should I use template literal types in TypeScript?

Use template literal types when you need string types that follow patterns, such as event handler names like onClick, dot-notation paths like server.host, or string transformations with Uppercase, Lowercase, and Capitalize utilities.

What are common pitfalls with advanced TypeScript types?

Common pitfalls include over-using any, ignoring strict null checks, creating overly complex types that slow compilation, missing discriminated union narrowing, and circular type references. Deeply nested conditional types can also degrade compiler performance.