المهارات typescript-advanced-types
📦

typescript-advanced-types

آمن

Master TypeScript Advanced Types

متاح أيضًا من: wshobson

Build type-safe applications with confidence using TypeScript's powerful type system. Learn generics, conditional types, mapped types, and utility types through practical examples.

يدعم: Claude Codex Code(CC)
🥉 74 برونزي
1

تنزيل ZIP المهارة

2

رفع في Claude

اذهب إلى Settings → Capabilities → Skills → Upload skill

3

فعّل وابدأ الاستخدام

اختبرها

استخدام "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

التدقيق الأمني

آمن
v1 • 2/25/2026

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.

2
الملفات التي تم فحصها
755
الأسطر التي تم تحليلها
0
النتائج
1
إجمالي عمليات التدقيق
لا توجد مشكلات أمنية
تم تدقيقه بواسطة: claude

درجة الجودة

38
الهندسة المعمارية
100
قابلية الصيانة
87
المحتوى
50
المجتمع
100
الأمان
91
الامتثال للمواصفات

ماذا يمكنك بناءه

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.

جرّب هذه الموجهات

Basic Generic Function
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.
Conditional Type for Validation
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.
Mapped Type for API Responses
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.
Type-Safe Event System
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?
Use interface for object shapes with better error messages and declaration merging. Use type for unions, intersections, and complex type logic. Both can describe object shapes, but interfaces offer better extensibility.
When should I use generics versus union types?
Use generics when you need type flexibility while maintaining relationships between input and output types. Use union types when a value can be one of several specific types without type relationships.
How do conditional types work in TypeScript?
Conditional types use the extends keyword with a ternary-like syntax: T extends U ? X : Y. They enable type-level logic that selects types based on conditions, similar to if-else at the type level.
What are mapped types and when should I use them?
Mapped types iterate over property keys to transform existing types. Use them for creating variants like Partial, Readonly, or custom transformations that apply uniformly across all properties.
How can I test my TypeScript types?
Create type assertion helpers that verify expected types at compile time. Use patterns like AssertEqual<T, U> that resolve to true for matching types. Test edge cases and ensure type errors occur where expected.
What are template literal types used for?
Template literal types create string-based types with pattern matching. Use them for building type-safe string concatenation, path builders, event names, and enforcing consistent naming conventions.

تفاصيل المطور

بنية الملفات