> For the complete documentation index, see [llms.txt](https://lwin-moe-paing.gitbook.io/typescript-baby-by-lwin-moe-paing/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lwin-moe-paing.gitbook.io/typescript-baby-by-lwin-moe-paing/basic-typescript/ts-type-keyword.md).

# TS - Type keyword

<figure><img src="https://4062235122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7tekcoDYDaKhlNreT5uK%2Fuploads%2FbFYoXFdjnRk3xGe726MX%2FTypescript%20Custom%20Type%20Syntax.png?alt=media&amp;token=448e65e0-884b-44ca-b751-5592bd8cb547" alt=""><figcaption></figcaption></figure>

TypeScript မှာ `type` keyword ကို Custom Type ပြုလုပ်ဖို့ အသုံးပြုပါတယ် ။

<figure><img src="https://4062235122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7tekcoDYDaKhlNreT5uK%2Fuploads%2F4mGAM35Zz1Bi6XN1f0S5%2FTypescript%20Custom%20Type%20First%20Assign.png?alt=media&amp;token=a19bd445-8de6-4f8a-96a4-eb3b804bac74" alt=""><figcaption></figcaption></figure>

ဒီ နမူနာ Code ထဲမှာ `StringOrNumber` ဆိုတဲ့ Custom Type တစ်ခုပြုလုပ်ပါတယ် ။ နောက် constant variable `str` ကို annotation လိုက်ပါတယ် ။ ဒါ့ကြောင့်  string type နဲ့ number type ကို လက်ခံလို့ရသွားပါတယ် ။

လက်တွေ့မှာတော့ Object Type တွေကို Custom Type တည်ဆောက်ပြီး အသုံးပြုတာများပါတယ် ။ ပိုပြီးရှင်းလင်းသွားသလို ၊ ခဏခဏ ပြန်လည် အသုံးပြုချနိုင် (Resuable) ဖြစ်သွားတာကြောင့် ဖြစ်ပါတယ် ။

<figure><img src="https://4062235122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7tekcoDYDaKhlNreT5uK%2Fuploads%2FeOMmuCtnCZ6mG28rHkzL%2FTypescript%20Custom%20Type%20Keyword.png?alt=media&amp;token=bb8213e2-b715-436e-81d4-f6eb363e764c" alt=""><figcaption></figcaption></figure>

နမူနာ Code အရ  `type`  ကို အသုံးပြုပြီး `PersonType`  တစ်ခု လုပ်လိုက်ပါတယ် ။ အထဲမှာ Object Type ဖြစ်တဲ့အတွက် သက်ဆိုင်တဲ့ property နဲ့ တန်ဖိုး Type တွေကို သတ်မှတ်ထားပါတယ် ။ ပြီးတဲ့နောက် constant variable နှစ်ခုဖြစ်တဲ့ personOne နဲ့ personTwo အတွက် PersonType တစ်ခုတည်းကိုပဲ အသုံးပြုနိုင်သွားပါပြီ ။
