Typescipt environment for development


$ mkdir -p ~/projects/dev/ts/my-new-ts-project && cd ~/projects/dev/ts/my-new-ts-project
$ npm init -y
$ npm install --save-dev typescript ts-node


tsconfig.json


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


$ vi tsconfig.json


{
  "compilerOptions": {
    "strict": 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
  },
  "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"
  },
***


Eslint Jest for TypeScript


Webpack & TypeScript Setup

https://www.youtube.com/watch?v=sOUhEJeJ-kI


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