Strict Mode
Strict mode เปิดใช้ compiler flags หลายตัวพร้อมกันเพื่อให้ TypeScript ตรวจสอบ types เข้มงวดที่สุด ช่วยจับ bugs ได้มากขึ้น
Strict Flags
Section titled “Strict Flags”| Flag | คำอธิบาย |
|---|---|
| strictNullChecks | null/undefined ต้อง handle |
| strictFunctionTypes | Function params contravariant |
| strictBindCallApply | Bind/call/apply type-safe |
| strictPropertyInitialization | Properties ต้อง initialize |
| noImplicitAny | ต้องระบุ type เมื่อ infer ไม่ได้ |
| noImplicitThis | this ต้องมี type |
| alwaysStrict | Emit “use strict” |
| useUnknownInCatchVariables | catch error เป็น unknown |
Strict Mode Flow
Section titled “Strict Mode Flow”เข้าสู่ระบบเพื่อดูเนื้อหาเต็ม
ยืนยันตัวตนด้วยบัญชี Google เพื่อปลดล็อกบทความทั้งหมด
Login with Google