ClaudeTypeScript
منشئ أنواع TypeScript المتقدم

لماذا تهم هذه المطالبة
Advanced TypeScript types replace runtime validation with compile-time guarantees, catching bugs before they reach production.
فيم نستخدمها
TypeScript
المطالبة
Create TypeScript types for the described requirement. Use advanced features where appropriate: generics, conditional types, mapped types, template literal types, infer keyword. Include: 1) The type definition, 2) Usage examples, 3) What compile-time errors it catches, 4) Alternative approaches considered.
النتيجة
```typescript
// Deep partial that makes all nested properties optional
type DeepPartial = T extends object ? {
[P in keyof T]?: DeepPartial;
} : T;
// Type-safe event emitter
type EventMap = {
'user:created': { id: string; email: string };
'order:completed': { orderId: string; total: number };
};
type EventHandler = (payload: EventMap[K]) => void;
class TypedEmitter {
on(event: K, handler: EventHandler): void {}
emit(event: K, payload: EventMap[K]): void {}
}
```
**Catches**: Misspelled event names, wrong payload shapes, missing required fields.
تستبدل أنواع TypeScript المتقدمة التحقق في وقت التشغيل بضمانات مرحلة التحويل البرمجي، مما يتيح اكتشاف الأخطاء قبل وصولها إلى بيئة الإنتاج.
يوضح هذا الموجّه نهجاً منظمًا للتعامل مع TypeScript، مُنتجاً نتائج متسقة وعالية الجودة يمكن البناء عليها وتطويرها بشكل تكراري.