-
Notifications
You must be signed in to change notification settings - Fork 12.8k
tsc CLI: option to always exit with 0 exit code #13280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Not sure if there is enough utility for adding a new flag. waiting for other user scenarios. |
Could you elaborate on which errors are compile errors and which are not? I think shell scripting can help here, but I don't know what exactly you are after. |
To clarify, I want to run |
currently I solve the issue with |
For me, It is not a really solution, typescript should support it natively as there are some case we can not control the cli exec, eg: storybook. |
bump. this caused major issues in a popular and highly connected library |
Tried to use pre-commit hooks and this scenario arised: #!/bin/sh
RED="\033[1;31m"
GREEN="\033[1;32m"
NC="\033[0m"
linter_exit_code=1
tsc_exit_code=1
staged_js_files=$(git diff --cached --diff-filter=d --name-only | grep .ts$)
./node_modules/.bin/eslint $staged_js_files --quiet --fix
linter_exit_code=$?
./node_modules/.bin/tsc
tsc_exit_code=$?
git add -f $staged_js_files
if [ $linter_exit_code -ne 0 ]
then
echo "${RED} ❌ ESLint${NC}"
else
echo "${GREEN} ✔ ESLint${NC}"
fi
if [ $tsc_exit_code -ne 0 ]
then
echo "${RED} ❌ Typescript${NC}"
else
echo "${GREEN} ✔ Typescript${NC}"
fi
if [ $linter_exit_code != 0 && $tsc_exit_code != 0 ]
then
exit 1
else
echo "... Why?"
exit 0
fi |
I'm running #!/usr/bin/env bash
set -veufo pipefail
pnpx tsc -p . || echo "WARNING: tsc exited with status code $?" The Alternatively, you can use Bonus tip: You can check if it actually hard failed (didn't compile vs complaining about types) by checking if some file exists. These are the last 2 lines of my script:
That will confirm:
|
I'm building a TS monorepo. Adding |
If |
Here's my use case for this feature: I have a project that is gradually adopting TS and does not have 100% strict compliance yet. So, almost every time we run However, sometimes code gets checked in that breaks |
It would be nice if the tsc command had an option to always exit with a 0 exit code when there were compile errors. I want to run something in my script after compiling. Currently I have to do this:
However this workaround means all errors from
tsc
will be silently ignored, not just compile errors.The text was updated successfully, but these errors were encountered: