Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierVerified on Verified ToolsFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowFeatured on FazierVerified on Verified ToolsFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App Show

© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
TypeScript الأنواع المتقدمة - الدليل الشامل

TypeScript الأنواع المتقدمة - الدليل الشامل

أتقن أنواع TypeScript المتقدمة: الأنواع العامة والأنواع المساعدة والأنواع الشرطية وحراس الأنواع. الدليل الشامل للتطوير الآمن للأنواع.

typescriptأنواعجينيريكسعربيarabicبرمجة
by AntigravityAI
⭐0Stars
👁️4Views
.antigravity
# TypeScript الأنواع المتقدمة

تعلم مفاهيم TypeScript المتقدمة لبناء تطبيقات قوية وآمنة للأنواع.

## الأنواع العامة (Generics)

```typescript
// دالة عامة
function firstElement<T>(array: T[]): T | undefined {
  return array[0];
}

const numbers = firstElement([1, 2, 3]); // النوع: number
const strings = firstElement(["أ", "ب"]); // النوع: string

// واجهة عامة
interface ApiResponse<T> {
  data: T;
  success: boolean;
  message?: string;
  timestamp: Date;
}

interface User {
  id: string;
  name: string;
  email: string;
}

async function getUser(id: string): Promise<ApiResponse<User>> {
  const response = await fetch(`/api/users/${id}`);
  return response.json();
}
```

## الأنواع المساعدة (Utility Types)

```typescript
interface Product {
  id: string;
  name: string;
  price: number;
  description: string;
  stock: number;
  createdAt: Date;
}

// Partial - جميع الخصائص اختيارية
type ProductUpdate = Partial<Product>;

// Pick - خصائص محددة فقط
type ProductPreview = Pick<Product, "id" | "name" | "price">;

// Omit - استبعاد خصائص محددة
type NewProduct = Omit<Product, "id" | "createdAt">;

// Required - جميع الخصائص مطلوبة
type CompleteProduct = Required<Product>;

// Readonly - جميع الخصائص للقراءة فقط
type ImmutableProduct = Readonly<Product>;
```

## الأنواع الشرطية

```typescript
// نوع شرطي بسيط
type IsString<T> = T extends string ? true : false;

type Test1 = IsString<string>;  // true
type Test2 = IsString<number>;  // false

// استخراج نوع عنصر المصفوفة
type ArrayElement<T> = T extends (infer E)[] ? E : never;

type NumberElement = ArrayElement<number[]>; // number
```

## حراس الأنواع (Type Guards)

```typescript
interface Dog {
  type: "dog";
  bark: () => void;
}

interface Cat {
  type: "cat";
  meow: () => void;
}

type Pet = Dog | Cat;

// دالة حارس النوع
function isDog(pet: Pet): pet is Dog {
  return pet.type === "dog";
}

function petSound(pet: Pet) {
  if (isDog(pet)) {
    pet.bark(); // TypeScript يعلم أن pet هو Dog
  } else {
    pet.meow(); // TypeScript يعلم أن pet هو Cat
  }
}
```

## أنواع الخرائط (Mapped Types)

```typescript
interface Form {
  username: string;
  email: string;
  password: string;
}

// جعل جميع الحقول قابلة للـ null
type Nullable<T> = {
  [K in keyof T]: T[K] | null;
};

type NullableForm = Nullable<Form>;

// حقول مع دوال getter
type Getters<T> = {
  [K in keyof T as `get${Capitalize<string & K>}`]: () => T[K];
};

type FormGetters = Getters<Form>;
```

هذا الدليل يساعد المطورين الناطقين بالعربية على فهم نظام أنواع TypeScript بشكل كامل.

When to Use This Prompt

This typescript prompt is ideal for developers working on:

  • typescript applications requiring modern best practices and optimal performance
  • Projects that need production-ready typescript code with proper error handling
  • Teams looking to standardize their typescript development workflow
  • Developers wanting to learn industry-standard typescript patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their typescript implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
💡 Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • ✓ Always review generated code for security vulnerabilities before deploying
  • ✓ Test the typescript code in a development environment first
  • ✓ Customize the prompt output to match your project's coding standards
  • ✓ Keep your AI assistant's context window in mind for complex requirements
  • ✓ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this typescript prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For typescript projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...