type-only-imports
ما الذي تفعله
تفحص هذه المهارة عبارات الاستيراد في TypeScript وتعلّم الاستيرادات الخاصة بالأنواع فقط. وهي موجهة إلى المطورين الذين يريدون حزمًا أصغر ومشكلات تبعية أقل.
متى تستخدمها
- ✓عندما يستورد ملف TypeScript وحدات تُستخدم للأنواع فقط.
- ✓عندما تتضمن الحزمة وحدات يبدو أنها تُحمَّل للأنواع فقط.
- ✓عندما يُعدّ مشروع TypeScript جديد بقواعد استيراد نظيفة.
رابط المهارة
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/type-only-imports/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“نظام البناء عندي في TypeScript يسحب وحدة كبيرة أستخدمها للأنواع فقط. هل يمكنك إصلاح الاستيرادات؟”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
يجد الوكيل الاستيرادات المستخدمة للأنواع فقط ويغيّرها إلى import type. ثم يزيلها المترجم عند بناء الكود.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
Use import type for type-only imports
Regular imports cause the JavaScript runtime to evaluate and execute the imported module even when only a TypeScript type from that module is used. This can increase bundle size, introduce unintended side effects, and create circular dependency issues that are otherwise avoidable. Using import type makes the erased-at-runtime nature of type imports explicit and enables bundlers and the TypeScript compiler to handle them optimally.
Quick Reference
- import type is erased entirely at compile time — no runtime module evaluation
- Prevents accidentally importing a value when only a type is needed
- Reduces circular dependency issues caused by type-only relationships
- verbatimModuleSyntax in TypeScript 5 enforces this automatically
Check
Review the import statements in this TypeScript file and identify any imports where only types or interfaces are used. These should use import type instead of a regular import.
Fix
Convert the identified regular imports to import type where the imported binding is only used as a TypeScript type annotation and not as a runtime value.
Explain
Explain the difference between import and import type in TypeScript, why type-only imports should be declared explicitly, and how verbatimModuleSyntax enforces this at the compiler level.
Code Review
Inspect all import statements in this file. For each import, check whether the imported name appears only in type positions (annotations, generics, implements clauses) versus runtime positions (function calls, new, typeof). Flag any regular import that is used only as a type.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/javascript/type-only-imports
الأسئلة الشائعة
ماذا يفعل import type؟
يخبر المترجم أن الاستيراد يُحذف وقت البناء، فلا تُحمَّل أي وحدة وقت التشغيل.
ما هو verbatimModuleSyntax؟
هو إعداد في TypeScript 5 يفرض هذه القاعدة تلقائيًا، بحسب المهارة.
هل يساعد هذا في تقليل الاعتماد الدائري؟
تقول المهارة إن الاعتماد الدائري الذي يمكن تجنبه يمكن تقليله باستخدام الاستيرادات الخاصة بالأنواع فقط.
التفاصيل
الوصف الأصلي من المؤلف
Use when auditing import statements in TypeScript files, setting up a new TypeScript project, or investigating unexpected bundle inclusions from type-only dependencies.
الشعبية
- نجوم GitHub
- 75k
- الترتيب
- #3067
- الترخيص
- MIT
- آخر تحديث
- 31/10/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
frontendchecklist
75kيفحص شيفرة الواجهة الأمامية والصفحات الحية مقابل أكثر من 380 قاعدة للوصول وسرعة الأداء وتحسين محركات البحث والأمان، بأداة سطر أوامر.
frontend-checklist-global
75kيدقق مشروع الواجهة الأمامية وفق كل قواعد Front-End Checklist البالغ عددها 386، ويقدم إصلاحًا محددًا لكل مشكلة وجدت.
404-page
75kيتأكد من أن صفحة الصفحات غير الموجودة تقدم روابط مفيدة وتُرجع رمز حالة 404 حقيقيًا، لمساعدة الزوار التائهين على إيجاد طريقهم.
about-page
75kيراجع ما إذا كان لموقعك صفحة «من نحن» واضحة تشرح من يديره، لبناء الثقة لدى الزوار ومحركات البحث.
مهارات مشابهة
diffs
394kيتيح لوكيلك إنتاج فرق تعديلات حقيقي يمكن مشاركته، كرابط عرض أو ملف صورة، بدلاً من ملخص مكتوب يدوياً.
coding-agent
394kيساعد وكيلك على تسليم مهمة برمجة كبيرة إلى Codex أو Claude Code أو OpenCode كعامل في الخلفية، ثم متابعة تقدمها.
gh-issues
394kيساعد وكيلك على إيجاد مشكلات GitHub واختيار ما ستعمل عليه، وفتح طلبات سحب بالإصلاحات، ومتابعة تعليقات المراجعة.