Type Assertions
Type Assertions ช่วยบอก TypeScript ว่าค่านั้นเป็น type อะไร เมื่อเรารู้ดีกว่า TypeScript ใช้เมื่อ TypeScript infer type ผิดหรือไม่รู้ type ที่แท้จริง
รูปแบบ Type Assertions
Section titled “รูปแบบ Type Assertions”| Syntax | ตัวอย่าง | หมายเหตุ |
|---|---|---|
| as Type | value as string | แนะนำ |
| angle-bracket | <string>value | ใช้ไม่ได้ใน JSX |
| Non-null | value! | assert ว่าไม่ใช่ null/undefined |
Type Assertion Flow
Section titled “Type Assertion Flow”เข้าสู่ระบบเพื่อดูเนื้อหาเต็ม
ยืนยันตัวตนด้วยบัญชี Google เพื่อปลดล็อกบทความทั้งหมด
Login with Google