> 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/preparing-for-coding/typescript-package-installation.md).

# TypeScript Package Installation

TypeScript ဖိုင် တွေကို Browser , Runtime တွေကနေ တိုက်ရိုက် အလုပ်မလုပ်နိုင်တဲ့အတွက် JavaScript ဖိုင်ကိုပြန်ပြောင်းဖို့ လိုပါတယ် ။ ဒီလို ပြောင်းဖို့အတွက် ပထမဦးစွာ  `typescript` package ကို  globally install ပြုလုပ်ပါမယ် ။&#x20;

### Install `typescript` package

```shell
npm i typescript -g
```

typescript package ကို install လုပ်ပြီးသွားတဲ့အခါ `tsc` ဆိုတဲ့ command ကို အသုံးပြုလို့ရသွားမှာပါ ။  `tsc` command က `.ts` ဖိုင်တွေကို `.js` ဖိုင်အဖြစ် ပြောင်းလဲပေးနိုင်ပါတယ် ။ ဥပမာ အနေနဲ့ `index.ts` ဆိုတဲ့ typescript ဖိုင်တစ်ခု ကိုအရင်​ ပြုလုပ်ပြီး ၊ အောက်ပါ Code ကို Save လိုက်ပါမယ် ။

```typescript
const age: number = 20;
console.log(age);
```

ဒီ့နောက် Terminal ကိုဖွင့်ပြီး `tsc` command ကိုရိုက်ပြီး `js` ဖိုင်ကို ထုတ်ကြည့်ပါ ။

```shell
tsc index.ts
```

ဒါဆိုရင် ကိုယ့်စက်ထဲမှာ `index.js` ဆိုပြီး ဖိုင်အသစ်တစ်ခု အောက်က Code အတိုင်း ထွက်လာတာကို တွေ့ရမှာပါ ။  ထူးခြားချက်အနေနဲ့ typescript မှာသုံးခဲ့တဲ့ <mark style="color:red;">number</mark> type ကိုဖြုတ်ပြီး <mark style="color:red;">const</mark> နေရာမှာ var ကို ပြောင်းလဲထုတ်ပေးလိုက်တာကို တွေ့ရမှာပါ ။

```javascript
var age = 20;
console.log(age);
```

အခုလိုပုံစံနဲ့ `tsc`command က typescript code တွေကို `js` code တွေအဖြစ် compile လုပ်ပြီး ပြောင်းလဲပေးပါတယ် ။&#x20;

### Install `ts-node` package

ဒုတိယ package အနေနဲ့  `ts-node` ကိုလည်း globally install ပြုလုပ်ပါမယ် ။

```sh
npm i ts-node -g
```

package ကို install လုပ်ပြီးသွားတဲ့အခါ `ts-node` ဆိုတဲ့ command ကို အသုံးပြုလို့ရသွားမှာပါ ။ ဒီ command က `.ts` ဖိုင်တွေကို **runtime** မှာ တိုက်ရိုက် execute လုပ်ပေးနိုင်ပါတယ် ။ `.js` ဖိုင် မပြောင်းတော့ဘဲ အချိန်ကုန်သက်သာပြီး code debuging လုပ်တဲ့ အခါ သုံးကြပါတယ် ။&#x20;
