What problem does it solve?
Inline and duplicated type definitions lead to code bloat, reduced readability, and maintenance headaches in TypeScript projects. This Skill guides you in refactoring these into reusable, well-organized type definitions.
Core Features & Use Cases
- Identify Inline Types: Automatically detects object type literals, unnamed unions/intersections, and complex type expressions that need extraction.
- Design Type Structure: Guides on using interfaces for object shapes, type aliases for unions/primitives/functions, and generics for reusable patterns.
- Extract & Refactor: Moves inline types to named definitions, creating new type modules (
types.ts) and giving descriptive names.
- Optimize & Simplify: Replaces duplicate types, simplifies complex inline types, and applies utility types (
Omit, Partial) for conciseness.
- Use Case: Extract inline object types from
src/services/userService.ts into a new src/types/user.ts file, creating interfaces for UserInput and User, and updating all references for improved readability and maintainability.
Quick Start
Identify inline type definitions in src/components/ProductCard.tsx and extract them into a new src/types/product.ts file.