I added small typecheck
command to run during my ci in order to ensure that there are no type errors. It uses tsc from node modules i.e.
./node_modules/.bin/tsc --noEmit;
This runs fine and console logs correct errors however the command itself passes with successful exit code. Ideally I want it to throw an exception and exit with error code.
Is there a flag or some tsconfig option I am missing that allows this?
Ok after fiddling with this for a while I figured out an issue, I was calling ./node_modules/.bin/tsc --noEmit;
inside a bash script, so my full setup looked like this
typecheck.sh
#!/bin/sh
./node_modules/.bin/tsc --noEmit;
package.json
{
"scripts": {
"typecheck": "typecheck.sh"
}
}
And because it was within that script, it didn't throw an error, after some research I was able to make it throw correctly by altering my script to include set -e
, so in the end this does the trick
#!/bin/sh
set -e
./node_modules/.bin/tsc --noEmit;