advanced
Legacy Code Refactoring to TypeScript
Refactor a complex legacy module to modern TypeScript using SOLID principles.
📝 Nội dung Prompt
Act as a Senior Software Architect. You are presented with a legacy module written in older JavaScript that suffers from tight coupling, global state reliance, and lack of error handling. Your task is to: 1. Rewrite the code using modern TypeScript features, specifically utilizing generics and utility types. 2. Refactor the structure to strictly adhere to SOLID principles, decoupling dependencies where necessary. 3. Implement robust error handling with custom error classes. 4. Add JSDoc comments for all public interfaces. 5. Provide a detailed diff-style explanation justifying the architectural choices made to improve maintainability and testability.