npm install -g typescript
tsc -v
Version 4.7.4 などとバージョンが返ってきます
mkdir test-transpile-typescript
cd test-transpile-typescript
tsc --init
フォルダ「test-transpile-typescript」に「tsconfig.json」が作成されます
class Hoge {
private _id: string;
constructor(id: string) {
this._id = id;
}
get id(): string {
return this._id;
}
}
const hoge = new Hoge('MY-CODE');
console.log(hoge.id);
tsc
typescriptのエラーがなければトランスパイルが行われます。「sample.js」が生成されます。
・TS playground
https://www.typescriptlang.org/play
・StackBlitz
https://stackblitz.com/