TypeScript telah menjadi standar de facto di industri. Tahun 2025, hampir tidak ada alasan untuk tidak menggunakannya.
Apa yang TypeScript Berikan?
Static Type Checking
function greet(name: string): string {
return Hello, ${name}!
}
greet(42) // ❌ Error: Argument of type 'number' is not assignable to type 'string'
Interface dan Type
interface User {
id: number
name: string
email: string
role: 'admin' | 'member' | 'su'
}
type ApiResponse<T> = { data: T message: string status: number }
Generics
function first<T>(arr: T[]): T | undefined {
return arr[0]
}
const num = first([1, 2, 3]) // type: number | undefined const str = first(['a', 'b']) // type: string | undefined
Manfaat Nyata di Tim
Bug tertangkap saat development, bukan di production
IDE autocomplete yang akurat
Refactoring lebih aman
Kode sebagai dokumentasi
Cara Mulai
npm install -D typescript @types/node
npx tsc --init
Mulai dengan strict: false, naikkan secara bertahap.