Build type-safe applications with confidence using TypeScript's powerful type system. Learn generics, conditional types, mapped types, and utility types through practical examples.
تنزيل ZIP المهارة
رفع في Claude
اذهب إلى Settings → Capabilities → Skills → Upload skill
فعّل وابدأ الاستخدام
اختبرها
استخدام "typescript-advanced-types". Create a generic merge function that combines two objects and preserves their types
النتيجة المتوقعة:
function merge<T, U>(obj1: T, obj2: U): T & U { return { ...obj1, ...obj2 }; }
const result = merge({ name: 'John' }, { age: 30 });
// Type: { name: string } & { age: number }
// Usage: result.name (string), result.age (number)
استخدام "typescript-advanced-types". Create a utility type that makes all nested properties readonly
النتيجة المتوقعة:
type DeepReadonly<T> = {
readonly [P in keyof T]: T[P] extends object
? T[P] extends Function ? T[P] : DeepReadonly<T[P]>
: T[P];
};
// Usage: All nested properties become immutable at compile time
التدقيق الأمني
آمنStatic analyzer detected 76 patterns but all are false positives. The skill contains documentation-only content with TypeScript code examples in markdown format. No executable code, network calls, or security risks present. All detected patterns are from code snippets used for educational purposes.
درجة الجودة
ماذا يمكنك بناءه
Type-Safe Library Development
Build reusable libraries and frameworks with strong type guarantees that provide excellent developer experience.
Complex API Client Design
Create type-safe API clients with automatic inference of request parameters, response types, and error handling.
Enterprise Application Architecture
Implement robust type systems for large-scale applications with complex data models and state management.
جرّب هذه الموجهات
Create a generic function that accepts any type and returns the same type. Show how TypeScript infers the type automatically and how to explicitly specify it.
Design a conditional type that checks if a type extends another type. Use it to create a type-level validation system for common data types like strings, numbers, and arrays.
Create a mapped type that transforms all properties of an API response type to be optional and readonly. Include key remapping to add getter methods.
Implement a complete type-safe event emitter using generics, conditional types, and template literal types. Support multiple event types with their specific payload types.
أفضل الممارسات
- Use unknown instead of any to enforce type checking before operations
- Prefer interface for object shapes and type for unions and complex types
- Leverage TypeScript's type inference and avoid unnecessary type annotations
تجنب
- Overusing any type which defeats TypeScript's type safety guarantees
- Creating overly complex types that slow down compilation and reduce readability
- Ignoring strict null checks which can lead to runtime errors in production
الأسئلة المتكررة
What is the difference between interface and type in TypeScript?
When should I use generics versus union types?
How do conditional types work in TypeScript?
What are mapped types and when should I use them?
How can I test my TypeScript types?
What are template literal types used for?
تفاصيل المطور
المؤلف
sickn33الترخيص
MIT
المستودع
https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/typescript-advanced-typesمرجع
main
بنية الملفات