Skip to content

Allow all error messages from tsc compiler to have their severity customized #61557

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

Closed
6 tasks done
alandsidel opened this issue Apr 9, 2025 · 2 comments
Closed
6 tasks done

Comments

@alandsidel
Copy link

πŸ” Search Terms

compiler custom error severity

βœ… Viability Checklist

⭐ Suggestion

Some errors can be enabled or disabled via setting certain flags to true or false in the tsconfig.json file. It would be nice if these errors could have their severity set as well.

πŸ“ƒ Motivating Example

During development and testing it is common to comment out a block of code and then compile and run it again.
In certain circumstances this causes novel errors to appear, for example if you comment out all uses of a variable or function argument, you must additionally remove the declaration of the variable or prefix the argument with an underscore to avoid errors such as TS6133. As such notices can be disabled and leave functioning code, via knobs like noUnusedLocals and noUnusedParameters, they are not truly errors.

There should be a compiler-wide option to emit such "errors" as warnings, so testing can proceed without further code modifications, as such modifications are prone to being accidentally left behind, as are such compiler configuration flags.

πŸ’» Use Cases

  1. What do you want to use this for?
    Testing and debugging of code.

  2. What shortcomings exist with current approaches?
    You can only turn these errors on, preventing compilation entirely, or off, which causes them to be ignored completely. This forces you to decide between making further code modifications to do testing, which may introduce errors, or to disable the compiler options, which may cause the unwanted code smell to be left. A warning would allow the code to run but continually draw the developers eye until it is addressed, which is the historic purpose of having warnings as a step between clean compiler output and show-stopping error output.

  3. What workarounds are you using in the meantime?
    There are no workarounds. I am disabling compiler options such as noUnusedLocals and noUnusedParameters in some cases, prefixing arguments with underscores in others, and then undoing those changes after the debugging is complete -- only to have to do it all again the next time.

@MartinJohns
Copy link
Contributor

MartinJohns commented Apr 9, 2025

Duplicate of #13408.

You can only turn these errors on, preventing compilation entirely, or off, which causes them to be ignored completely. This forces you to decide between making further code modifications to do testing, which may introduce errors, or to disable the compiler options, which may cause the unwanted code smell to be left.

Imo that's what noEmitOnError set to false is there for. The checks still happen, but your code is compiled as well.

@alandsidel
Copy link
Author

alandsidel commented Apr 9, 2025

Imo that's what noEmitOnError set to false is there for. The checks still happen, but your code is compiled as well.

I wasn't even aware of this option, thanks for the pointer. It turns out that it defaults to false anyway, so the code is being compiled even with the errors being printed. The exit code of tsc being non-zero lead me to believe it was aborting compilation.

I'd still rather these kinds of non-fatal issues were emitted as warnings and not errors for the reason outlined, but I can work with this.

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

2 participants