Skip to content

Latest commit

 

History

History
64 lines (53 loc) · 998 Bytes

23-TypeScript.md

File metadata and controls

64 lines (53 loc) · 998 Bytes

TypeScript & NodeJS

Setup

  • npm install typescript @types/node --save-dev
  • tsc --init

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["es2015"],
    "rootDir": "src",
    "outDir": "dist",
    "module": "commonjs",
    "moduleResolution": "node",
    "strict": true,
    "declaration": true,
    "sourceMap": true,
    "inlineSources": true,
    "types": ["node", "mocha"]
  },
  "include": ["src/**/*"]
}

package.json

{
  "scripts": {
    "build": "tsc"
  },
  "devDependencies": {
    "@types/node": "^10.12.11",
    "typescript": "^3.2.1"
  }
}

Testing

{
  "scripts": {
    "test": "mocha dist/**/*.spec.js -R spec --bail"
  }
  "devDependencies": {
    "@types/mocha": "^5.2.5",
    "mocha": "^5.2.0",
  }
}

Resources