🏠 Home / Hub 🏠 Back to Hub

🔷 TypeScript

Type-safe JavaScript | Bug တွေ code ရေးတုန်း ဖမ်းနိုင်, IDE support အကောင်းဆုံး

01

Types & Variables

string, number, boolean, any, unknown, union

02

Interfaces & Types

interface, type alias, optional fields, readonly

03

Functions

Typed params/return, overloads, arrow functions

04

Classes & OOP

class, access modifiers, abstract, implements

05

Generics

Generic functions, classes, constraints, utility types

06

TypeScript + Vue

defineProps, ref<T>, composables, Vite + TS setup

07

Decorators

Class, method, property decorators — @Log, @Memoize, @Singleton, DI container

08

Advanced Types

Conditional types, mapped types, template literals, discriminated unions, infer

Prerequisites: JavaScript (js_01 - js_08) — TypeScript = JavaScript + Types
Setup: npm install -g typescripttsc --inittsc file.ts
Playground: typescriptlang.org/play — browser မှာ TS run ကြည့် (setup မလို!)

⚡ TypeScript Quick Reference

// Basic types
let name: string = "Ko Ko";
let age: number = 25;
let active: boolean = true;
let items: string[] = ["a","b","c"];

// Union & Optional
let id: string | number = "abc";
let email?: string;          // optional

// Interface
interface User {
  id: number;
  name: string;
  email?: string;            // optional field
  readonly createdAt: Date;  // can't change
}

// Function
function greet(name: string): string {
  return `Hello, ${name}!`;
}

// Generic
function first<T>(arr: T[]): T {
  return arr[0];
}
const num = first([1, 2, 3]);    // T = number
const str = first(["a","b"]);    // T = string

📌 Study Checklist