# 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;


---

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