> 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/other-topic/typescript-template-literal.md).

# TypeScript Template Literal

Template Literal က string literal types တွေကို ပေါင်းစပ်ပြီး dynamic type တွေဖန်တီးနိုင်တဲ့ feature တစ်ခုပဲဖြစ်ပါတယ်။

<figure><img src="https://4062235122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7tekcoDYDaKhlNreT5uK%2Fuploads%2FwzNmGwfgwlMN2ppAm7rb%2FTypescript%20Literal.png?alt=media&amp;token=8e1fa655-4ff8-4765-a61d-7f284749f0d1" alt=""><figcaption></figcaption></figure>

Hello, နဲ့စမယ် ကြားထဲ ကြိုက်တယ့်စာသား String ကို အသုံးပြုနိုင်ပြီး နောက်ဆုံးမှာ (!) နဲ့ပိတ်မယ့် Template Literal Type လေးဖန်တီးကြည့်ပါမယ် ။

<figure><img src="https://4062235122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7tekcoDYDaKhlNreT5uK%2Fuploads%2F9mTNTuU4WZiRHrUgy3ag%2FTypescript%20Literal%20Example%201.png?alt=media&amp;token=7b78b933-c2dc-4e63-b61a-5041b1a5996d" alt=""><figcaption></figcaption></figure>

Greeting Template Literal Type လေးဖန်တီးထားပါတယ် ။&#x20;

ပထမ helloWorld variable ကတော့ အဆင်ပြေပါတယ် ။&#x20;

ဒုတိယ wrongWorld variable ကတော့ "," "!" တွေ မပါဝင်တဲ့အတွက် Error Feedback ပြန်ရမှာ ဖြစ်ပါတယ်။

Union String Literal တွေ သုံးပြီးတော့လည်း ရေးသားနိုင်ပါတယ် ။

<figure><img src="https://4062235122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7tekcoDYDaKhlNreT5uK%2Fuploads%2FibuSw5xlVMoUNCZPd30x%2FTypescript%20Literal%20Example%202.png?alt=media&amp;token=79884565-3d02-4b41-9bcc-991775419618" alt=""><figcaption></figcaption></figure>

တကယ့်လက်တွေ့မှာ အသုံးပြုလေ့ရှိတယ့် Code Example fetchAPI ဆိုတဲ့ Function ကိုလေ့လာကြည့်ပါမယ် ။

<figure><img src="https://4062235122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7tekcoDYDaKhlNreT5uK%2Fuploads%2FPnaUnQnKD6ycE0K9Mbp8%2FTypescript%20Literal%20Example%203.png?alt=media&amp;token=f0996133-ea9f-4424-9076-3f27ea4c5877" alt=""><figcaption></figcaption></figure>

ရေးထားတဲ့ Template အရ /api နဲ့စမှ မှန်ကန်မှာဖြစ်ပါတယ် ။<br>
