Setting up type checking for JavaScript

  1. npm install typescript --save-dev installs TypeScript locally
  2. npx tsc --init --allowJs --checkJs --noEmit creates tsconfig.json
  3. Add "check-types": "npx tsc" to the scripts object in package.json
  4. Run npm run check-types to check types

Type annotations can be written with JSDoc syntax. I often refer to Jsdoc cheatsheet.

Further reading