Modules และ Namespaces
TypeScript รองรับทั้ง ES Modules (แนะนำ) และ Namespaces (legacy) สำหรับจัดการ code ให้เป็นระเบียบ ควรใช้ ES Modules สำหรับโปรเจกต์ใหม่
เปรียบเทียบ
Section titled “เปรียบเทียบ”| Feature | ES Modules | Namespaces |
|---|---|---|
| Syntax | import/export | namespace |
| Scope | File-based | Global/nested |
| Bundling | Tree-shakeable | ไม่ได้ |
| Recommendation | ใช้เสมอ | Legacy only |
Module System
Section titled “Module System”เข้าสู่ระบบเพื่อดูเนื้อหาเต็ม
ยืนยันตัวตนด้วยบัญชี Google เพื่อปลดล็อกบทความทั้งหมด
Login with Google