> 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="/files/myDU6Xstyu3hn2BbWowK" alt=""><figcaption></figcaption></figure>

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

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

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

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

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

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

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

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

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

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