# TS - satisfies

<figure><img src="/files/5IDgPGwi2c4l6eSxRUsx" alt=""><figcaption></figcaption></figure>

TypeScript မှာ satisfies operator က (၂) မျိုးလုပ်ဆောင်ပေးပါတယ် ။&#x20;

အရင်ဆုံး Target Type နဲ့ Type-Checking လုပ်ပါတယ် ။&#x20;

ပြီးတဲ့နောက် Type Safe ဖြစ်တဲ့ လုပ်ဆောင်ချက်ကို ထည့်ပေးပါတယ် ။

satisfies ရဲ့ Type-Checking လုပ်ဆောင်ပုံကို အရင်လေ့လာကြည့်ပါမယ် ။

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

constant variable ဖြစ်တဲ့ user ထဲကို တန်ဖိုးတွေ assign လုပ်ထားပါမယ် ။&#x20;

သူ့ရဲ့ အနောက်မှာ satisfies operator `TargetType` ကို ကပ်ပြီးရေးထားတဲ့ ပုံစံဖြစ်ပါတယ် ။

ဘယ်ဘက်ပုံအရ  property `id` အတွက် တန်ဖိုး `"100"` ဖြစ်ပါတယ် ။ UserType ထဲမှာလည်း `id: string` ဖြစ်တာကြောင့် Type-Checking မှန်ပါတယ် ။ ဒုတိယ property `strOrNo: string | number` မှာ `strOrNo: "Lwin Moe Paing"` မို့လို့ Type-Checking မှန်ပါတယ် ။  ဒါကြောင့် ဘယ်ဘက် Code မှာ Type Checking Pass ဖြစ်သွားပါတယ် ။

ညာဘက် Code မှာ age ဆိုတဲ့ property က User Type ထဲမှာ မရှိပါဘူး ။ ဒါကြောင့် Type-Checking က မှားနေကြောင်း TypeScript Server က Error ပြသွားမှာပါ ။

satisfies operator ရဲ့ Type Safe ဖြစ်တဲ့ လုပ်ဆောင်ချက်ကို ထပ်လေ့လာသွားပါမယ် ။

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

ဘယ်ဘက် ပုံက User Type ကို `satisfies` နဲ့ အသုံးပြုထားပါတယ် ။ သူက Type-Checking ပြီးသွားတဲ့ အခါ Type-Safe ဖြစ်အောင်ဆက်လုပ်ပါတယ် ။ နမူနာ Code ထဲမှာ user.strOrNo ဆိုတဲ့ property value က "Lwin Moe Paing" ပါဒါ့ကြောင့် string type ဆိုတာ သေချာသွားပြီလို့ ယူဆလိုက်ပါတယ် ။ user.strOrNo(.) ဆိုပြီး ခဏထားလိုက်တဲ့အခါ string method တွေကိုပဲ TypeScript Server က feedback တွေပေးသွားမှာပါ ။

ညာဘက်ပုံက User Type ကို annotation နည်းနဲ့ တန်ဖိုးကိုထည့်လိုက်ပါတယ် ။ ser.strOrNo(.) ဆိုပြီး ခဏထားလိုက်တဲ့အခါ type က string | number ဖြစ်နေတဲ့အတွက် string နဲ့ number မှာ ဘုံတူတဲ့ method တွေကိုပဲ feedback ပေးသွားမှာပါ ။

ဒါက ရိုးရိုး Type ကိုကြေငြာတာနဲ့ Satisfies ရဲ့ အသုံးပြုပုံ ကွာခြားချက်ပဲ ဖြစ်ပါတယ် ။

Code ရေးသားပုံ အပြည့်အစုံကို လေ့လာကြည့်နိုင်ပါတယ် ။

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lwin-moe-paing.gitbook.io/typescript-baby-by-lwin-moe-paing/basic-typescript/ts-satisfies.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
