
以下のコマンドをターミナルで実行
※ Node.js推奨版がインストールされていることが前提の手順
mkdir ts; cd ts; npm init -y; npm i -D typescript; npx tsc --init; touch index.html index.ts; echo '<script src="index.js"></script>' > index.html
あとはindex.tsを修正してnpx tscコマンドを実行すればindex.jsが生成される。
1 2 3 | // index.ts 修正例 const h: string = 'Hello' console.log(h) |
ターミナルでnode index.jsを実行するかindex.htmlをブラウザで開けばconsole.logの確認などができるようになる。