Skip to content
เข้าสู่ระบบ

Type Assertions

Type Assertions ช่วยบอก TypeScript ว่าค่านั้นเป็น type อะไร เมื่อเรารู้ดีกว่า TypeScript ใช้เมื่อ TypeScript infer type ผิดหรือไม่รู้ type ที่แท้จริง

Syntaxตัวอย่างหมายเหตุ
as Typevalue as stringแนะนำ
angle-bracket<string>valueใช้ไม่ได้ใน JSX
Non-nullvalue!assert ว่าไม่ใช่ null/undefined
Diagram

เข้าสู่ระบบเพื่อดูเนื้อหาเต็ม

ยืนยันตัวตนด้วยบัญชี Google เพื่อปลดล็อกบทความทั้งหมด