typescript-advanced

Encode complex domain constraints into compile-time TypeScript types.

41|4|Updated May 6, 2026
One-click install
npx skills add https://github.com/markerikson/opencode-config-example --skill typescript-advanced-markerikson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-advanced
Source: https://github.com/markerikson/opencode-config-example/tree/main/config/skill/typescript-advanced
Command: npx skills add https://github.com/markerikson/opencode-config-example --skill typescript-advanced-markerikson

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Complex TypeScript codebases often struggle to express real domain constraints at compile time, leading to weaker type safety, fragile APIs, and harder refactors.

Core Features & Use Cases

  • Advanced type system patterns: generics with constraints, conditional types with infer, and distributive conditional types for precise type transformations.
  • Structural type modeling: mapped types (including key remapping and filtering), template literal types for typed strings and paths, and branded types to prevent mixing compatible primitives.
  • Safer runtime modeling via types: discriminated unions, type guards, and assertion functions to enable reliable narrowing and compile-time correctness for state machines and reducers.
  • Deep reusable utilities: deep utility types (DeepPartial/DeepReadonly/DeepRequired), plus practical examples like a type-safe event emitter and type-state builder patterns.

Quick Start

Ask for a TypeScript advanced type utility that uses generics plus conditional types with infer to validate and transform a complex domain model into a strongly typed API surface.

Frequently Asked Questions about typescript-advanced

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

FAQPage Schema
How do I encode complex domain constraints into compile-time TypeScript types?

You can encode domain constraints using generics with bounds, conditional types with infer, and mapped types to transform complex models into a strongly typed API surface. This prevents invalid states and unsafe API usage at compile time.

What's the best way to prevent mixing compatible primitives in TypeScript?

The best way to prevent mixing compatible primitives is using branded types for nominal safety. This technique tags primitive values at the type level, ensuring distinct domain concepts like UserId and OrderId remain incompatible during assignments.

How do I use advanced TypeScript types to model state machines and reducers?

Model state machines by defining discriminated unions for states and transitions, then apply type guards and assertion functions to enable reliable type narrowing. This guarantees compile-time correctness for reducers processing typed event contracts.

Can I build type-safe event emitters using conditional and mapped types in TypeScript?

Yes, you can build type-safe event emitters by applying conditional types with infer and mapped types for key remapping. This approach validates event payloads and ensures listeners receive strongly typed arguments matching the emitted event contracts.

Why do I need distributive conditional types when building reusable TypeScript utilities?

Distributive conditional types are needed to apply type transformations over unions automatically, ensuring utility types like DeepPartial or DeepReadonly map correctly across each constituent. This prevents losing type precision when manipulating complex domain models.

Does TypeScript support template literal types for validating typed string paths?

Yes, TypeScript supports template literal types to validate and constrain typed string paths. By combining them with mapped types, you can extract and enforce path structures, enabling strongly typed property access and inference-heavy transformations.