TypeScript Type System Designer
Designs TypeScript type architectures — branded types, discriminated unions, generics with constraints, template literal types — matched to your application's complexity tier. The goal it optimizes for is developer experience: types that make invalid states unrepresentable and give autocomplete that guides usage, not type gymnastics for their own sake.
The Prompt
Design robust TypeScript type systems for complex applications with full IDE autocomplete support. **Application Type:** [WEB APP / API / LIBRARY / CLI TOOL / DATA PROCESSOR] **Complexity Level:** [SIMPLE FORMS / MEDIUM STATE MANAGEMENT / COMPLEX ENTERPRISE] **Type System Components to Design:** - Utility Types: Custom Pick, Omit, Partial, Required variants for domain-specific needs - Discriminated Unions: Event types, state machines, API response variants with type-safe handling - Conditional Types: Type transformations based on input characteristics (e.g., flatten nested objects) - Mapped Types: Dynamic property generation from templates (readonly variants, nullable overrides) - Template Literal Types: Route path typing, event name typing, CSS class name generation - Generic Constraints: Repository patterns, service interfaces with type-safe method signatures **Deliverables:** - Complete type definitions file with JSDoc comments - Form validation schemas with typed error messages - API response typing with automatic error handling types - State management types (Redux/Zustand stores) with action payload types - Event system typing with typed listeners and emitters - Full IDE autocomplete examples showing intellisense in action **Output:** Production-ready type definitions that compile cleanly and provide excellent developer experience.
How to Customize It
Replace each bracketed placeholder with your own details before running the prompt. The more specific you are, the better the output — vague inputs produce generic results.
[WEB APP / API / LIBRARY / CLI TOOL / DATA PROCESSOR]Swap in your web app or api or library or cli tool or data processor.[SIMPLE FORMS / MEDIUM STATE MANAGEMENT / COMPLEX ENTERPRISE]Swap in your simple forms or medium state management or complex enterprise.
When to Use It
- Typing a complex domain (orders, permissions, state machines) where stringly-typed code keeps producing runtime bugs.
- Designing the public types for a library or SDK where consumers' autocomplete experience is the product.
- Refactoring an `any`-riddled codebase incrementally — get a target type design before touching code.
Tips for Better Results
- 1Describe the invalid states you want to make impossible ("an order can't be both shipped and cancelled") — that constraint drives the whole design.
- 2Ask for the simple version alongside the clever one; a type junior teammates can't read has a real maintenance cost.
- 3Request usage examples with expected compiler errors — types are only verified by attempting to misuse them.
Want a Version Tailored to You?
Load this template into the AI Prompt Generator to customize it for your specific use case, or browse the full library for more.
Related Prompts
React Component Architect
Designs React components to production standard in one pass: TypeScript props contract, state placement decisions, accessibility (keyboard, ARIA, focus management), loading/error/empty states, and performance notes.
Code Documentation Generator
Transforms code into layered documentation: docstrings, README sections, API references, architecture overviews, and onboarding guides matched to the output format you need.
Code Review Assistant
Runs pasted code through a structured senior-engineer review: security vulnerabilities and resource leaks first, then performance, then maintainability and style, with each finding explained rather than just flagged.
Explain Code Like I'm Five
Explains pasted code through four escalating lenses: a one-sentence summary, a real-world analogy, a line-by-line walkthrough, and the "why" behind non-obvious choices.