🦁

TypeScript environment setting

2021/10/20に公開

Excute below command in any directory .

$ yarn init
$ yarn add -D typescript @types/node
$ touch tsconfig.json

tsconfig.json

{
  "compilerOptions": {
    "lib": ["ESNext"],
    "module": "CommonJS",
    "outDir": "dist", 
    "sourceMap": true,
    "strict": true,
    "target": "ES2015"
  },
  "include": ["src"]
}

In excute below command in current directory .

$ mkdir src
$ touch src/index.ts
$ mkdir dist

Add any souce code in index.ts

How to exucute index.ts

$ yarn tsc
$ node dist/index.js

Discussion