Typescipt environment for development


$ mkdir -p ~/projects/dev/ts/my-new-ts-project && cd ~/projects/dev/ts/my-new-ts-project


$ npm init -y
$ yarn add --dev typescript ts-node
$ yarn add --dev @types/node


tsconfig.json


// You can generate default tsconfig.json
// $ ./node_modules/.bin/tsc --init


$ vi tsconfig.json


{
  "compilerOptions": {
    "strict": true,
    "noImplicitAny": true,
    "target": "esnext",
    "module": "commonjs",
    "baseUrl": "./src",
    "rootDir": "./src",
    "outDir": "./build",
    "allowJs": false,
    "moduleResolution": "node",
    "sourceMap": true,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "skipLibCheck": true,
    "removeComments": true,
    "esModuleInterop": true,
    "downlevelIteration": false,
    "noFallthroughCasesInSwitch": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "noPropertyAccessFromIndexSignature": true,
    "noUncheckedIndexedAccess": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true
  },
  "exclude": ["node_modules"],
  "include": ["./src/**/*.ts", "./test/**/*.ts"]
}


Can be helpful if tests not needed.

"exclude": ["node_modules", "**/*.spec.ts"],


Compiler Options
https://www.typescriptlang.org/docs/handbook/compiler-options.html


$ vi package.json


package.json

***
"scripts": {
    "build": "NODE_PATH=./src tsc",
    "ts-node": "NODE_PATH=./src ts-node ./src/index.ts",
    "lint": "NODE_PATH=./src eslint src --ext js,ts,jsx,tsx",
    "test": "NODE_PATH=./src jest"
  },
***


Nodemon Eslint Jest for TypeScript WebPack for TypeScript


Example

Example from video course [FrontendMasters] Production-Grade TypeScript


https://github.com/mike-north/professional-ts


Configured project:
https://github.com/mike-north/professional-ts-my-lib