Type Narrowing
Type Narrowing คือกระบวนการที่ TypeScript จำกัด type ให้แคบลงจาก union หรือ broad type เป็น specific type ผ่าน control flow analysis
ทำไม Narrowing สำคัญ
Section titled “ทำไม Narrowing สำคัญ”| ข้อดี | คำอธิบาย |
|---|---|
| Type Safety | เข้าถึง properties ได้อย่างปลอดภัย |
| Autocomplete | IDE รู้ว่ามี methods อะไรบ้าง |
| Error Prevention | ไม่เรียก method ที่ไม่มี |
Narrowing Flow
Section titled “Narrowing Flow”เข้าสู่ระบบเพื่อดูเนื้อหาเต็ม
ยืนยันตัวตนด้วยบัญชี Google เพื่อปลดล็อกบทความทั้งหมด
Login with Google