ts-starter
https://3.bp.blogspot.com/-wfJhC04GulI/W64DxSdEjiI/AAAAAAABPJc/8sWSdDW-2IAGl-QvG0aCSMq9S9t8uLPbwCLcBGAs/s400/music_animal_cat_sax.png
TypeScript で Node.js 向けのコードを書きたいなと思ったときにすぐ用意できるやつです。
この記事の中身そのものが実行されます。記事の実行ってちょっと斬新よね。
code:使い方(bash)
/icons/hr.icon
スターターの中身
code:setup(bash)
curl -s -O $endpoint/package.json
curl -s -O $endpoint/tsconfig.json
curl -s -O $endpoint/index.ts
which -s yarn && yarn install || npm install
code:package.json
{
"name": "sandbox",
"scripts": {
"start": "ts-node ./index.ts"
},
"dependencies": {
"@types/node": "^14.0.1",
"ts-node": "^8.10.1",
"typescript": "^3.9.2"
}
}
code:tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"strict": true,
"noEmit": true,
}
}
code:index.ts
(async () => {
})()
.catch((e) => {
console.error(e)
process.exit(1)
})