> 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-union-keys-in-index.md).

# TS - Union keys in Index

<figure><img src="/files/dzzi89ZKNiwZzchidfvm" alt=""><figcaption></figcaption></figure>

TypeScript မှာ Union Type `(|)` ကို အသုံးပြုပြီး Object Type ကို ပြုလုပ်နိုင်ပါတယ် ။&#x20;

Syntax အရ `[key in UnionType ] : ValueType` ရေးသားနည်းပါ ။

<figure><img src="/files/hjI4lTSQaFPPsIQh9oAF" alt=""><figcaption></figcaption></figure>

နမူနာ Code အရ "name" | "age" | "email" ဆိုတဲ့ `UserKeys` Union Type ရှိပါမယ် ။

`[key in UserKeys]` ကို အသုံးပြုပြီး Union ထဲမှာပဲ ပါတဲ့ တန်ဖိုးတွေကို Key အဖြစ် သုံးလိုက်တာပါ ။

အခုလို ရေးသားနည်းနဲ့ Object တွေကို Dynamic ဖန်တီး ယူလို့ရပါတယ် ။
