> 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-unknown-and-any.md).

# TS - Unknown & Any

### Unknown & Any

<figure><img src="https://4062235122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7tekcoDYDaKhlNreT5uK%2Fuploads%2FKiGdCkv1PAaDO3TXC0Uk%2FTypescript%20Unknown%20%26%20Any%20Syntax.png?alt=media&amp;token=255853e5-81ad-421c-bb32-ba2ddb58c889" alt=""><figcaption></figcaption></figure>

`let unData : unknown = "hello";` ရေးထုံးနဲ့ `unknown` Type တွေကို သတ်မှတ် လို့ရပါတယ် ။

`let anyData : any = "hello";` ရေးထုံးနဲ့ `any` Type တွေကို သတ်မှတ် လို့ရပါတယ် ။ &#x20;

Priority Level ကို အရင် ကြည့်ရအောင် ။

<figure><img src="https://4062235122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7tekcoDYDaKhlNreT5uK%2Fuploads%2FU6ZZG9efHqFqtRfB37ly%2FTypeScript%20Unknown%20%26%20Any%20Level.png?alt=media&amp;token=f3569d55-04c2-4f99-8d51-f27a348b3df1" alt=""><figcaption></figcaption></figure>

`unknown` နဲ့ `any` type က Priority Level  အမြင့်ဆုံးတွေဖြစ်ပါတယ် ။\
&#x20;ဒီ Type တွေကို သတ်မှတ်ထားတဲ့အခါ အခြားတန်ဖိုးတွေအကုန် လက်ခံနိုင်ပါတယ် ။

### Any Type

ဘယ်လို Data type မဆို ကိုင်တွယ်နိုင်တဲ့ Flexible Type ဖြစ်ပါတယ် ။&#x20;

Strict Type-Checking ကို Disable လုပ်နိုင်စွမ်းရှိပါတယ် ။&#x20;

<figure><img src="https://4062235122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7tekcoDYDaKhlNreT5uK%2Fuploads%2FgOn9OEMXZplmVaFS4ZO2%2FTypeScript%20Any%20Error.png?alt=media&amp;token=1c1a8d0f-c0c7-49fc-99c3-5af5768112b9" alt=""><figcaption></figcaption></figure>

`any` Type ကို တတ်နိုင်သလောက် ရှောင်ပြီး သုံးသင့်ပါတယ် ။ \
သို့ပေ့မယ် လည်း Legacy JavaScript Code တွေကို Migrate လုပ်တဲ့အခါ ၊ API response ကို Handle လုပ်တဲ့အခါမှာ `any` Type ကို အသုံးပြုလေ့ ရှိကြပါတယ် ။

### Unknown Type

TypeScript မှာ `unknown` ကို `any` အစား Type-Safe အနေနဲ့ သုံးကြပါတယ် ။

သူလည်းပဲ အခြား Type အားလုံးကို Assign လုပ်လို့ရပါတယ် ။ သို့ပေ့မယ် `any` နဲ့ မတူတာက `method` `properties` တွေကို တိုက်ရိုက် ယူသုံးလို့ မရတာပဲဖြစ်ပါတယ် ။

<figure><img src="https://4062235122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7tekcoDYDaKhlNreT5uK%2Fuploads%2Ft8egnBbaORGn7ivNcMOF%2FTypeScript%20Unknown%20Error.png?alt=media&amp;token=3ff4c70d-4f0c-4905-89b9-25f3fe3665ef" alt=""><figcaption></figcaption></figure>
