typescript-advanced-patterns

Implement advanced TypeScript type patterns for compile-time error detection.

181|30|Updated Nov 16, 2025
One-click install
npx skills add https://github.com/curiositech/some_claude_skills --skill typescript-advanced-patterns-curiositech
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-advanced-patterns
Source: https://github.com/curiositech/some_claude_skills/tree/main/.claude/skills/typescript-advanced-patterns
Command: npx skills add https://github.com/curiositech/some_claude_skills --skill typescript-advanced-patterns-curiositech

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps you write more robust and maintainable TypeScript code by leveraging advanced type system features to catch errors at compile time, rather than at runtime.

Core Features & Use Cases

  • Nominal Typing: Differentiate between types that have the same underlying structure (e.g., UserId vs. OrderId).
  • Discriminated Unions: Model states or shapes that can be one of several distinct possibilities, with type safety.
  • Type-Safe APIs: Use Zod for runtime validation and compile-time type inference for API request/response schemas.
  • Compile-Time Guarantees: Eliminate common runtime bugs by encoding constraints directly into your types.

Quick Start

Use the typescript-advanced-patterns skill to generate branded types for UserId and OrderId based on the provided string type.

Frequently Asked Questions about typescript-advanced-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent mixing up structurally identical TypeScript types like UserId and OrderId?

Branded types implement nominal typing in TypeScript to differentiate structurally identical types like UserId and OrderId, catching assignment errors at compile time rather than runtime.

How does Zod schema inference work for type-safe API request and response validation?

Zod schema inference provides type-safe APIs by validating runtime data against a schema and automatically inferring the matching TypeScript type, ensuring API requests and responses are strictly validated and type-checked.

What is the best way to model multiple distinct application states with discriminated unions in TypeScript?

Discriminated unions model distinct application states in TypeScript by narrowing object shapes based on a literal property, enabling exhaustive switch checking and compile-time guarantees for state handling.

Can I encode domain constraints directly into TypeScript types to catch errors at compile time?

You can encode domain constraints directly into TypeScript types using template literal types, conditional types, and branded types, shifting error detection to compile time and eliminating common runtime bugs.

When do I need template literal types and conditional types in a TypeScript codebase?

Template literal types and conditional types are needed when building advanced type-safe patterns like type-safe event emitters, deriving and validating types dynamically based on string manipulations and conditions for compile-time error detection.