ENع
الدرس 12 · Advanced and in practice

Mapped and conditional types

لم يُترجم بعد؛ يُعرض باللغة الإنجليزية

In TypeScript you can build a new type out of an old one. Follow one seven-line file as keyof lists User's keys, a mapped type loops over them, T[K] looks up each key's type, and a conditional type turns numbers into strings. tsc computes Form = { id: string; name: string; admin: boolean }, then uses it to catch a wrong value.

12 دقيقة9 خطوات5 أسئلةAdvanced
شكل 12 · تفاعلي
جارٍ تحميل الرسم…
أو ← →

اختبار يتاح بعد الخطوة الأخيرة.