Setting up type checking for JavaScript
npm install typescript --save-dev
installs TypeScript locallynpx tsc --init --allowJs --checkJs --noEmit
creates tsconfig.json- Add
"check-types": "npx tsc"
to thescripts
object in package.json - Run
npm run check-types
to check types
Type annotations can be written with JSDoc syntax. I often refer to Jsdoc cheatsheet.