Open5
TypeScriptメモ
npm init -y
npm install typescript
npm install @types/node -D
vim install-with-types.sh
install-with-types.sh
#!/usr/bin/env bash
npm install $1
npx typesync
npm install
chmod +x install-with-types.sh
package.json
{
"scripts": {
"i": "./install-with-types.sh"
}
}
npx tsc --init
Created a new tsconfig.json with:
TS
target: es2016
module: commonjs
strict: true
esModuleInterop: true
skipLibCheck: true
forceConsistentCasingInFileNames: true
You can learn more at https://aka.ms/tsconfig
vim example.ts
example.ts
console.log("hello world");
実行
npx ts-node example.ts
hello world