Skip to content

TS-1: Type System พื้นฐาน

TypeScript เพิ่ม static type system เข้ามาใน JavaScript ทำให้เราจับ bug ได้ตั้งแต่ตอนเขียนโค้ด ไม่ต้องรอ runtime

เป้าหมายการเรียนรู้

Section titled “เป้าหมายการเรียนรู้”
  • เข้าใจ Basic Types ทั้งหมดของ TypeScript: string, number, boolean, array, tuple, enum, any, unknown, void, never
  • ใช้ Interfaces และ Type Aliases ในการกำหนดโครงสร้างข้อมูลได้อย่างถูกต้อง
  • เข้าใจ Union Types, Literal Types และ Discriminated Unions สำหรับการจัดการข้อมูลหลายรูปแบบ
Progress 0 / 3

ทำไมต้องเรียน Type System?

Section titled “ทำไมต้องเรียน Type System?”

ในงาน UX/UI Engineering การทำงานกับข้อมูลคือหัวใจสำคัญ:

  • API Response — ข้อมูลจาก backend มีโครงสร้างที่ต้องเข้าใจ
  • Component Props — React component ต้องการ props ที่ถูก type
  • State Management — state ที่ไม่มี type ทำให้เกิด bug ง่าย
  • Form Data — ข้อมูลจาก form ต้อง validate ก่อนส่ง

บทเรียนในบทนี้

Section titled “บทเรียนในบทนี้”
  • ความรู้ JavaScript พื้นฐาน (variables, functions, objects)
  • ติดตั้ง Node.js และ TypeScript (npm install -g typescript)
  • Code editor ที่รองรับ TypeScript (แนะนำ VS Code)