Skip to content
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

TypeScript preConversion doesn't consider error code or stderr output #209

Open
owickstrom opened this issue Sep 1, 2017 · 2 comments
Open

Comments

@owickstrom
Copy link

The script used in the TypeScript preConvert stage doesn't:

  • Consider the error code returned by tsc
  • Output compilation errors to stderr

The existing script is (with line breaks):

TMP_IN=$(mktemp XXXXXXXXXX.ts);
TMP_OUT=$(mktemp XXXXXXXXXX.js);
cat /dev/stdin > ${TMP_IN} && tsc --out ${TMP_OUT} ${TMP_IN} && cat ${TMP_OUT};
rm ${TMP_IN} && rm ${TMP_OUT}

To improve on the situation the script could:

  • Use traps to always remove temp files, and have the tsc command as the last one, thus returning tsc's error code
  • Redirect the output from stdout to stderr

Something like this (I've tested in this in a custom ShakespeareSettings value):

TMP_IN=$(mktemp XXXXXXXXXX.ts);
TMP_OUT=$(mktemp XXXXXXXXXX.js);
trap "rm ${TMP_OUT};" EXIT;
trap "rm ${TMP_IN};" EXIT;
cat /dev/stdin > ${TMP_IN} && tsc --out ${TMP_OUT} ${TMP_IN} 1>&2 && cat ${TMP_OUT}

If this sounds good I can submit a PR.

Thanks for this library, by the way! 🙂

@owickstrom owickstrom changed the title TypeScript doesn't consider error code or stderr output TypeScript preConversion doesn't consider error code or stderr output Sep 1, 2017
@snoyberg
Copy link
Member

snoyberg commented Sep 3, 2017

I'm not familiar with the TypeScript code, but this sounds reasonable. @gregwebs do you have any input?

@gregwebs
Copy link
Member

gregwebs commented Dec 3, 2017

sounds good to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants