typescript-advanced-types

Create type-safe TypeScript code using generics, conditional, mapped, and template literal types.

5|Updated Oct 17, 2011
One-click install
npx skills add https://github.com/klen/dotfiles --skill typescript-advanced-types-klen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-advanced-types
Source: https://github.com/klen/dotfiles/tree/main/.config/opencode/skills/typescript-advanced-types
Command: npx skills add https://github.com/klen/dotfiles --skill typescript-advanced-types-klen

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers write more robust, type-safe, and maintainable TypeScript code by leveraging advanced type system features.

Core Features & Use Cases

  • Generics: Create reusable components that work with various types.
  • Conditional Types: Build types that change based on other types.
  • Mapped Types: Transform existing types into new ones.
  • Template Literal Types: Create string-based types for precise string manipulation.
  • Utility Types: Utilize built-in types like Partial, Required, Pick, Omit.
  • Use Case: When building a type-safe API client, you can use advanced types to ensure that request parameters and response structures are correctly typed, preventing runtime errors.

Quick Start

Use the typescript-advanced-types skill to generate a type-safe event emitter for user-related events.

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 API client in TypeScript to prevent runtime errors?

Use TypeScript utility types like Partial, Required, Pick, and Omit to transform existing types into new ones, extracting or modifying specific properties to create reusable type structures without duplicating definitions.

How do I build complex type inference logic in TypeScript for reusable components?

Build complex type inference logic by combining TypeScript generics with conditional types, allowing your reusable components to dynamically adapt their type signatures based on the specific types passed in during usage.

What are template literal types in TypeScript and when do I need them?

Template literal types in TypeScript are advanced types for precise string manipulation, allowing you to create string-based types by combining literal strings and unions. You need them when enforcing specific string patterns at compile time.

How do I generate a type-safe event emitter for user-related events in TypeScript?

Generate a type-safe event emitter by applying TypeScript mapped types and generics to strictly define event names and their corresponding payload structures, ensuring that listeners receive correctly typed arguments.

Does this TypeScript types skill require any specific dependencies or components?

No, this TypeScript types skill has zero dependencies and requires no specific components, making it directly accessible for developers looking to implement compile-time type safety in sophisticated projects without external tooling.