TypeScript
تعلّم TypeScript من البداية حتى النهاية. الأنواع، interfaces، generics، classes، modules، utility و mapped types، ملفات التصريح، والمترجم.
18 درسًا، بالترتيب
- 120 دقيقة
مرحباً يا TypeScript
هذا برنامج JavaScript صغير ومعطوب تماماً، ومع ذلك ستشغّله JavaScript براحة بال:
What TypeScript isTsc compile stepRunning a .ts fileThe play button - 225 دقيقة
أساسيات الأنواع (Type)
تستطيع الآن تشغيل ملف .ts. لنتعرّف إذًا على لبنات البناء الأولى: الأنواع الأولية التي يأتي بها TypeScript، ومعها المخرجان (any وunknown) اللذان ستقرأ...
Primitive typesStringNumberBooleanNullUndefined+3 - 325 دقيقة
المصفوفات والـ Tuples
القيمة الواحدة نادراً ما تكفي. عندك قائمة درجات حرارة، وقائمة أسماء، وقائمة أسعار. وما إن تصير عندك قائمة حتى يفتح صنف جديد من الأخطاء بابه: القائمة...
Array typesReadonly arraysTuple typesFixed-length tuplesNamed tuple elements - 425 دقيقة
أنواع الكائنات (Type) والـ Interfaces
الأنواع البدائية والمصفوفات تقطع بك شوطاً طويلاً، لكن لأغلب البيانات الحقيقية شكلاً: للمستخدم اسم وعمر، وللطلب طريقة ومسار، وللنتيجة حالة ومتن. وتتيح...
Object literal typesInterface keywordRequired vs optional propertiesStructural typingExcess property checks - 525 دقيقة
الدوال
الدوالّ هي المكان الذي تسكنه أكثر الأخطاء البرمجية، وهي المكان الذي تؤتي فيه الأنواع أكبر ثمرة. وتوقيع الدالّة (أي بارامتراتها ونوع القيمة التي...
Parameter typesReturn typesVoid returnDefault parametersRest parametersFunction type expressions+1 - 625 دقيقة
Union و Literal Types
بعض القيم ليست شيئًا واحدًا. فالدالة التي تبحث عن مستخدم إما أن تجده أو لا تجده. وحقل النموذج يحمل إما عددًا كتبه المستخدم وإما لا شيء بعد. والطلب...
Union typesString literal typesNumeric literal typesLiteral narrowing with as constUnion of object shapes - 730 دقيقة
تضييق الأنواع (Type Narrowing)
النوع الاتحادي (union) يقول: «هذه القيمة واحدة من عدة أنواع». والتضييق هو العملية التي يعرف بها المترجِم أيها بالضبط، اعتمادًا على الفحوص التي تكتبها...
Typeof narrowingTruthiness narrowingEquality narrowingIn operator narrowingInstanceof narrowingDiscriminated unions+1 - 820 دقيقة
Type Aliases مقابل Interfaces
كنت تكتب أشكال الكائنات في مكانها مباشرة، ولم تكن هناك مشكلة لأن الأشكال كانت صغيرة. وهذا الآن توقيع دالة من قاعدة كود حقيقية:
Type aliasesInterface declarationsExtending interfacesIntersection typesDeclaration mergingWhen to pick which - 925 دقيقة
Optional و Readonly و Nullable
أكثر أخطاء وقت التشغيل شيوعاً في JavaScript يبدو هكذا:
Optional propertiesReadonly propertiesNon-null assertion operatorOptional chainingNullish coalescingStrictNullChecks - 1020 دقيقة
Enums
بعض القيم تأتي من قائمة قصيرة ثابتة. الطلب إمّا قيد الانتظار أو مشحون أو مُسلَّم. سطر السجل إمّا تصحيح أو معلومة أو تحذير أو خطأ. الاتجاه إمّا أعلى...
Numeric enumsString enumsConst enumsEnums vs string literal unionsReverse mapping caveats - 1130 دقيقة
Generics
تحتاج دالة تأخذ مصفوفة وتعيد أول عنصر فيها. سهلة:
Generic functionsGeneric interfacesType parametersType inference for genericsBounded generics with extendsDefault type parameters - 1225 دقيقة
الـ Classes
هذا حساب بنكي مكتوب ككائن عادي:
Class declarationsConstructorsInstance propertiesAccess modifiers (public, private, protected)Readonly fieldsParameter properties+1 - 1325 دقيقة
الوراثة والـ Abstract Classes
كتبتَ ثلاثة أصناف لنظام مدفوعات: CardPayment وBankTransfer وVoucher. الثلاثة كلها لها amount وcurrency وcreatedAt. الثلاثة كلها لها دالة describe()...
Extends keywordSuper callsMethod overrideAbstract classesAbstract methodsImplements with interface - 1425 دقيقة
الـ Modules
كل ملف TypeScript وحدة برمجية (module) قائمة بذاتها. فما إن يحتوي الملف على import أو export حتى تكفّ أسماؤه في المستوى الأعلى عن كونها عامة وتصير...
ES module syntaxNamed exportsDefault exportType-only importsRe-exportsModule resolution basics - 1530 دقيقة
Utility Types
يأتي TypeScript ومعه مكتبة صغيرة من الأنواع العامة تأخذ نوعاً مدخلاً وتُرجع نوعاً محوَّلاً. أسماؤها متواضعة (Partial و Pick و Omit و Record وغيرها)...
Partial<T>Required<T>Readonly<T>Pick<T, K>Omit<T, K>Record<K, V>+2 - 1630 دقيقة
Mapped و Conditional Types
الأنواع المساعدة التي استعملتها للتو (Partial و Pick و Record و ReturnType) كلها مبنية من ميزتين في اللغة: الأنواع المُعيَّنة (mapped types) لتحويل...
Keyof operatorMapped types syntaxKey remapping with asConditional typesInfer keywordDistributive conditional types - 1725 دقيقة
ملفات التصريح (Declaration Files) والمكتبات
تثبّت مكتبة، وتستوردها، فإذا بمحررك يعرض لك الإكمال التلقائي وتلميحات المعاملات وبنية كل قيمة مُعادة بدقة. ثم تثبّت مكتبة أخرى، وتستوردها بالطريقة...
.d.ts filesDefinitelyTyped (@types packages)Ambient declarationsDeclare moduleTypeRoots and types option - 1830 دقيقة
tsconfig والمترجم (Compiler)
tsconfig.json هو الملف الذي يقرأه مترجم TypeScript ليعرف ما الذي يترجمه وكيف. فيه أكثر من مئة خيار، لكن أي مشروع حقيقي لا يستعمل منها إلا اثني عشر أو...
Tsconfig.jsonStrict modeTarget and libModule and moduleResolutionOutDir and rootDirIncremental and watch+1
تعلّم TypeScript بلغتك
كل درس واختبار ورد من المدرس يظهر بلغتك. المدرس الذكي يرد بنفس اللغة التي تكتب بها.
Roles that use TypeScript
See how hiring teams interview engineers on TypeScript, in production-like environments.
Frontend Engineer (React, Angular, Vue)
Hire frontend engineers in real workspaces with Vite, real component libraries and real performance budgets. Live or take-home, fully recorded.
See the interviewFull Stack Developer
Hire full stack developers in real apps with real APIs, real UIs and real tests. Live or take-home, fully recorded.
See the interviewWeb Application Engineer
Hire web application engineers in real apps with real routes, real auth and real test suites. Live or take-home, fully recorded.
See the interview