> 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="https://4062235122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7tekcoDYDaKhlNreT5uK%2Fuploads%2FYUNlOLPEfi938H8MKTgk%2FTypescript%20Union%20Key%20Indexing%20Syntax.png?alt=media&amp;token=84f16862-2309-4293-b21a-067006ab9665" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="https://4062235122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7tekcoDYDaKhlNreT5uK%2Fuploads%2FOR7AZtGMCo8sSo6lRB1O%2FTypescript%20Union%20Key%20Indexing%20Code.png?alt=media&amp;token=2692d0d4-3c50-4398-be4d-56da0820231a" alt=""><figcaption></figcaption></figure>

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

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

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