TS ファイルのコンパイルと実行
指定した TS ファイルをコンパイル
tsc コマンドにより index.ts をコンパイルする。
$ tsc index.ts
実行後に index.js が作成される。 index.js の動作を確認する場合は node から実行する。
$ node index.js
watch オプションはファイルの更新をチェック、コンパイルする。
$ tsc index.ts --watch
ts.coinfig
init オプションにより tsconfig.json ファイルを作成。
$ tsc --init
tsc コマンドにより *.ts ファイルをコンパイルする。 ※オプションは詳細はtsconfig.jsonに記述
$ tsc
監視する場合は同様に watch オプションを使用する。
$ tsc --watch
ts-node
TypeScirpt ファイルを実行する。
npm から ts-node をインストール。次のように実行する。
$ npx ts-node src/main.ts