We have set up a git hook in our app using Husky for pre-commit actions.
Whenever someone commits code, it triggers the pre-commit code -
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm use
npx lint-staged
And in the package.json file, we have -
"lint-staged": {
"*.(js|ts|vue)": "eslint --cache --fix --max-warnings=0"
}
The current setup catches lint errors effectively but does not flag issues in the TypeScript codebase, such as calling a non-callable variable -
https://i.sstatic.net/rkT7o.png
Even though this passes the lint check.
I understand that only lint is being run, but is there a straightforward way to also validate TypeScript? The only option currently available is running a build, which is too time-consuming for a commit hook.
Any suggestions or assistance on adding TypeScript validation will be highly appreciated. Thank you!