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

Strict Mode

Strict mode เปิดใช้ compiler flags หลายตัวพร้อมกันเพื่อให้ TypeScript ตรวจสอบ types เข้มงวดที่สุด ช่วยจับ bugs ได้มากขึ้น

Flagคำอธิบาย
strictNullChecksnull/undefined ต้อง handle
strictFunctionTypesFunction params contravariant
strictBindCallApplyBind/call/apply type-safe
strictPropertyInitializationProperties ต้อง initialize
noImplicitAnyต้องระบุ type เมื่อ infer ไม่ได้
noImplicitThisthis ต้องมี type
alwaysStrictEmit “use strict”
useUnknownInCatchVariablescatch error เป็น unknown
Diagram

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

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